Help needed: Packaging .so files into .apk

798 views
Skip to first unread message

RagsSuper!

unread,
Mar 2, 2015, 6:33:06 PM3/2/15
to andro...@googlegroups.com
 

I understand this is asked many times, but I have done thorough research before posting my query.

I have updated Android Studio to latest version as of March 2nd 2015, version 1.1.0. I think still grade does not package .so files on its own.

I have written NewNDK.c in /jni folder. Ran the ndk-build script and .so files were created in /libs. As per suggestion in one of the posts, I modified libs to lib.

Even then, I am getting java.lang.UnsatisfiedLinkError: Couldn't load from loader dalvik.system.PathClassLoader findLibrary returned null error.

The posts does not say about which files to modify. I am new to Android, request your help.

I have narrowed down the problem to: 1. Gradle is not packaging 2. Gradle scripts should be modified.

The build.gradle (Module: app) is as below:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.raghu.newndk"
        minSdkVersion 17
        targetSdkVersion 17
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
}

The build.gradle (project) is as below:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

Please let me know what is missing.

Thank You!

Mine

unread,
Mar 2, 2015, 10:21:01 PM3/2/15
to android-ndk
Simply add below line in build.gradle fixes your issue.

jniLibs.srcDirs = ['path/to/libs']

You can refer here: http://stackoverflow.com/questions/21096819/jni-and-gradle-in-android-studio

--
BRs,
Lei YU


--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk...@googlegroups.com.
To post to this group, send email to andro...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-ndk.
For more options, visit https://groups.google.com/d/optout.

RagsSuper!

unread,
Mar 4, 2015, 10:36:29 AM3/4/15
to andro...@googlegroups.com
Hi Lei YU,

Thank you very much. I was stuck for long time. I successfully loaded the .so files.
Reply all
Reply to author
Forward
0 new messages