gpt4 book ai didi

gradle - build.gradle 有什么问题?得到 UnsatisfiedLinkError 因为它缺少我的 so 文件

转载 作者:行者123 更新时间:2023-12-03 05:01:17 25 4
gpt4 key购买 nike

我将项目升级到 com.android.tools.build:gradle-experimental:0.6.0-beta5
并做了http://tools.android.com/tech-docs/new-build-system/gradle-experimental 中描述的所有事情

但是,在运行应用程序时有一个异常(exception):

02-23 23:45:56.731 30326-30326/my.android.project I/art: Late-enabling -Xcheck:jni
02-23 23:45:57.056 30326-30326/my.android.project D/AndroidRuntime: Shutting down VM
02-23 23:45:57.059 30326-30326/my.android.project E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.android.project, PID: 30326
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/my.android.project-2/base.apk"],nativeLibraryDirectories=[/data/app/my.android.project-2/lib/arm64, /data/app/my.android.project-2/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]] couldn't find "libjni-utils.so"
at java.lang.Runtime.loadLibrary(Runtime.java:367)
at java.lang.System.loadLibrary(System.java:1076)
at my.android.project.JNIutils.<clinit>(JNIutils.java:10)
at my.android.project.ApplicationContext.onCreate(ApplicationContext.java:66)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4707)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

项目的 Build.gradle:
// 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-experimental:0.6.0-beta5"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

allprojects {
repositories {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

/app/build.gradle
apply plugin: 'com.android.model.application'

model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles.add(file("proguard-rules.txt"))
signingConfig = $("android.signingConfigs.release")
}
}

defaultConfig {
applicationId "my.android.project"
minSdkVersion.apiLevel 16
targetSdkVersion.apiLevel 23
versionCode 214
versionName "2alpha14"
}

ndk {
moduleName "native"
ldLibs.add("log")
cppFlags.add("-std=c++11")
cppFlags.add("-fexceptions")
stl "gnustl_shared"
}
}

android.signingConfigs {
create("release") {
storeFile "C:\\Android\\Git\\project\\keystore\\keystoreTTC"
storePassword "[CENSORED]"
keyAlias "[CENSORED]"
keyPassword "[CENSORED]"
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}

本地属性
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Mon Jan 04 15:04:21 CET 2016
ndk.dir=C\:\\Android\\sdk\\ndk-bundle
sdk.dir=C\:\\Android\\sdk

和 gradle-wrapper.properties
#Sun Feb 07 11:11:15 GMT 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

构建过程中没有错误。

出了什么问题?

备注
.c 文件位于其默认位置 \project\app\src\main\jni\jni-utils.c

最佳答案

您的应用正在尝试加载 libjni-utils.so,但您的模块被命名为 native,而不是 jni-utils。

在您的 build.gradle 文件中,更改此行:

moduleName "native"


moduleName "jni-utils"

关于gradle - build.gradle 有什么问题?得到 UnsatisfiedLinkError 因为它缺少我的 so 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35590682/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com