Hello World not working in Android Studio 3

829 Views Asked by At

I've downloaded Android Studio 3 canary 6. I created a project using the empty activity and targeted it to run on Android 4.0(Ice Cream Sandwitch) and above. When Running the app on the actual device that uses android Kitkat 4.4 (I've tried in two different devices) I get "unfortunally app stopped working". I didn't touch any of the code generated by the empty activity project. What can cause this issue?. Where do I start to look to solve this problem?. I'm reading a book and I followed all the steps so it should work.

updated

logcat:

    java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.example.teste03/br.com.example.teste03.MainActivity}: 
android.content.res.Resources$NotFoundException: Resource ID #0x7f060052
2

There are 2 best solutions below

0
On

I recommend updating your android studio to the latest available version on the beta channel, Beta 4 is available right now

https://developer.android.com/studio/preview/index.html

Also need to check your gradle settings, you said you are targeting 4.0 and above, to target 4.0 and above you will need this on your app level gradle

    android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.test.helloworld"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
           }
        }
     }

Hope it helps

0
On

With the logcat information I found that adding

 android.enableAapt2=false 

to grade.properties solves the problem. I don't know why, I'm just start learning Android development.