Android version 2.2 “Primary migration development issue”

Before moving on to AS 2.2, I have the following structure for implementing my C

app/src/main/jni/Android.mk app/src/main/jni/Application.mk app/src/main/jni/headers/* app/src/main/jni/cfiles*.cc 

and in this case everything is built perfectly. However, after upgrading to AS 2.2, I cannot create any apk and always get the following error:

Execution failed for task':app:transformNative_libsWithStripDebugSymbolForDebug java.lang.NullPointerException (no error message)

Does anyone know why this is? I can't seem to find a job.

+7
android android-studio android-gradle android-ndk gradle
source share
7 answers

I felt that many of these decisions were redundant. Sorry for the answer to my own question, but the actual solution was taken from just about every post here!

Like what @GregT said, I was working on updating the NDK package that I installed. And by doing this, they actually modified the *.mk files, as did @Matthew_Bondarchuk's answer.

Therefore, as @aaronvargas said, this is a mistake; in particular, the Android NDK system was not updated due to updates that were installed in Android Studio 2.2. This leads to incompatibility with the Android build tools, as @Michael_Jess said.

+1
source share

I solved this problem in my project) try adding this to my build.gradle (module)

  externalNativeBuild { ndkBuild { path 'src/main/jni/Application.mk' } } 

Gradle link to your native library

+1
source share

This morning I upgraded to AS 2.2 and had the same error. Upgrading NDK solved it for me. Now you can update using the SDK manager, instructions here:

https://developer.android.com/studio/projects/add-native-code.html#download-ndk

Also make sure your local.properties file points to the correct NDK location. Windows example local.properties:

 ndk.dir=C\:\\Users\\Me\\AppData\\Local\\Android\\sdk\\ndk-bundle sdk.dir=C\:\\Users\\Me\\AppData\\Local\\Android\\sdk 
+1
source share

This seems to be a bug in version 2.2.0 and above for gradle android build tools. Causing me problems in our CI environment.

Please run the error below!

https://code.google.com/p/android/issues/detail?id=223162

until we get back to the old version of tools before 2.1.3

+1
source share

We had the same error today in the Rajawali project, that is, we did not implement our own components, but used a library that implements some of our own OpenGL components. I suppose this has something to do with updating Android Studio (it was 2.2.3 on this machine), but I cannot clearly say at this point. It just "suddenly stopped working."

However, we had to go to the experimental tools for building Android and apply the Mike fix above to make it work. Migration guidance (somewhat outdated) can be found here . For reference, we only needed to adjust build.gradle and app/build.gradle , which now look like this:

 // build.gradle buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle-experimental:0.8.3' // used to be: 'com.android.tools.build:gradle:2.2.2' } } allprojects { repositories { mavenLocal() jcenter() } } 

... and

 //app/build.gradle apply plugin: 'com.android.model.application' // used to be 'com.android.application' // android() migrated according to guide // note that buildConfigFields() is missing, because it lead to errors model { android { compileSdkVersion 19 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.projecttango.experiments.augmentedrealitysample" minSdkVersion.apiLevel 19 targetSdkVersion.apiLevel 19 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles.add(file("proguard-rules.pro")) } } productFlavors { create("flavor1") { applicationId "com.app" } } sources { main { java { source { srcDir "src" } } } } // Fix suggested by Mike above ndk { platformVersion 21 } } } // Remaining Rajawali "noise" def external_lib_prefix = null if (project.hasProperty("Tango.catkin_devel_prefix")) { external_lib_prefix = project.property("Tango.catkin_devel_prefix") } else { // Building in standalone sample form. external_lib_prefix = "../../TangoReleaseLibs" } repositories { flatDir { dirs external_lib_prefix + '/aar' } } dependencies { compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar']) compile (name: 'tango_support_java_lib', ext: 'aar') compile 'org.rajawali3d:rajawali: 1.1.668@aar ' } 

Once you're done, make sure you sync your Gradle project in Android Studio. Otherwise, when you try to start right away, you will see something like Task 'generateDebugSources' not found in project ':app' .

+1
source share

I tried various settings, the one that fixed this problem for me changed the Version platform from "19" on which it was installed to "21" in the {android {ndk section in build.gradle application. This will be relevant only in the experimental version. I am building with compileSdkVersion set to 24, and buildToolsVersion at 24.0.2.

0
source share

Update the build.gralde configuration in the app module:

 compileSdkVersion 23 buildToolsVersion "24.0.2" 

Here is my compileSdkVersion and buildToolsVersion , which affects me, that you need to update your compileSdkVersion and buildToolsVersion to the greatest match with your gradle-plugin version .

In short, as soon as you update your gradle-plugin version , you should also update your configuration in build.gradle to make sure that you can get the correct result.

0
source share

All Articles