我想知道如何构建我的APK,以便在安装APK时在/data/data/
我正在使用Android 4.0.1我构建一个APK,并确认当我提取它时,我有一个包含我的jni库的lib/arm64-v8a文件夹。我希望在我安装我的APK之后,在同一个设备上的一些其他应用程序可以访问我在lib/arm64-v8a中拥有的库。/data/data/
我确实在/data/app/下面看到了一个包含库的文件夹,但是它们包含了每次安装APK时随机设置的字符串:
代码语言:javascript复制/data/app/~~sFE8-eNknFAkhKJ-1S03lg==/
base.apk
lib/arm64/
我还安装了其他预构建的APK,使用这些程序,我确实看到了/data/data/
这是我的分级文件:
代码语言:javascript复制import java.util.regex.Matcher
import java.util.regex.Pattern
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
lintOptions {
checkReleaseBuilds false
abortOnError false
}
sourceSets.main {
jniLibs.srcDirs = ['libs']
jni.srcDirs = []
}
defaultConfig {
applicationId "com.example.myexample"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
version "3.17.0"
cppFlags ""
arguments "-DANDROID_STL=c++_shared"
}
}
ndk {
moduleName "myexample"
abiFilter "arm64-v8a"
ldLibs "log"
}
packagingOptions {
exclude "lib/arm64-v8a/libassets.so"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
version "3.17.0"
path "src/main/cpp/CMakeLists.txt"
// There can be only one CMAKE per project: https://developer.android.com/studio/projects/gradle-external-native-builds
}
}
}
task copyFiles(type: Copy) {
description = 'Testing a manual copy operation (confirmed it works)...'
from file("../dsp/external/ship/libmyexample_skel.so")
into file("$buildDir/res/raw/")
}
project.afterEvaluate {
preBuild.dependsOn copyFiles
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}我还尝试过其他一些方法:我手动创建了一个src/main/jniLibs.arm64-v8a文件夹,其中放置了一个.so。当我解压缩它时,这个.so会出现在my中,但是我的/data/data/