我已成功使用默认包编译电报。但是,当我使用自己的包名重命名和重构所有包时,请通过以下链接https://stackoverflow.com/a/34323758/7531970更新jni子模块并创建jni .so,使用ndk 14b并输入所需的所有详细信息。但我仍然不断收到此错误,请帮助我
08-25 23:39:55.027 26920-26959/com.sipo.messenger E/FA: Uploading is not possible. App measurement disabled
08-25 23:39:55.027 26920-26920/com.sipo.messenger D/dalvikvm: DexOpt: couldn't find static field Landroid/os/Build;.SUPPORTED_ABIS
08-25 23:39:55.027 26920-26920/com.sipo.messenger W/dalvikvm: VFY: unable to resolve static field 183 (SUPPORTED_ABIS) in Landroid/os/Build;
08-25 23:39:55.027 26920-26920/com.sipo.messenger D/dalvikvm: VFY: replacing opcode 0x62 at 0x0006
08-25 23:39:55.047 26920-26920/com.sipo.messenger D/dalvikvm: Trying to load lib /data/app-lib/com.sipo.messenger-2/libtmessages.27.so 0x4292cbd0
08-25 23:39:55.247 26920-26920/com.sipo.messenger D/dalvikvm: Added shared lib /data/app-lib/com.sipo.messenger-2/libtmessages.27.so 0x4292cbd0
08-25 23:39:55.257 26920-26920/com.sipo.messenger D/dalvikvm: Trying to load lib /data/data/com.sipo.messenger/files/lib/libtmessages.27loc.so 0x4292cbd0
08-25 23:39:55.347 26920-26920/com.sipo.messenger D/dalvikvm: Added shared lib /data/data/com.sipo.messenger/files/lib/libtmessages.27loc.so 0x4292cbd0
08-25 23:39:55.777 26920-26920/com.sipo.messenger D/dalvikvm: Trying to load lib /data/data/com.sipo.messenger/files/lib/libtmessages.27loc.so 0x4292cbd0
08-25 23:39:55.777 26920-26920/com.sipo.messenger D/dalvikvm: Shared lib '/data/data/com.sipo.messenger/files/lib/libtmessages.27loc.so' already loaded in same CL 0x4292cbd0
08-25 23:39:55.787 26920-26920/com.sipo.messenger W/dalvikvm: No implementation found for native Lcom/sipo/tgnet/ConnectionsManager;.native_setJava:(Z)V
08-25 23:39:55.787 26920-26920/com.sipo.messenger D/AndroidRuntime: Shutting down VM
08-25 23:39:55.787 26920-26920/com.sipo.messenger W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x41e8cda0)
08-25 23:39:55.797 26920-26920/com.sipo.messenger E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sipo.messenger, PID: 26920
java.lang.UnsatisfiedLinkError: Native method not found: com.sipo.tgnet.ConnectionsManager.native_setJava:(Z)V
at com.sipo.tgnet.ConnectionsManager.native_setJava(Native Method)
at com.sipo.messenger.ApplicationLoader.onCreate(ApplicationLoader.java:205)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1013)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4799)
at android.app.ActivityThread.access$1600(ActivityThread.java:170)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1377)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5662)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
这是我的傻瓜
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
configurations {
compile.exclude module: 'support-v4'
}
dependencies {
compile 'com.google.android.gms:play-services-gcm:11.0.2'
compile 'com.google.android.gms:play-services-maps:11.0.2'
compile 'com.google.android.gms:play-services-vision:11.0.2'
compile 'com.google.android.gms:play-services-wallet:11.0.2'
compile 'com.google.android.gms:play-services-wearable:11.0.2'
compile 'com.android.support:support-core-ui:25.3.1'
compile 'com.android.support:support-compat:25.3.1'
compile 'com.android.support:support-core-utils:25.3.1'
compile 'com.android.support:support-v13:25.3.1'
compile 'com.android.support:palette-v7:25.3.1'
compile 'net.hockeyapp.android:HockeySDK:4.1.3'
compile 'com.googlecode.mp4parser:isoparser:1.0.6'
compile 'com.stripe:stripe-android:2.0.2'
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
useLibrary 'org.apache.http.legacy'
defaultConfig.applicationId = "com.sipo.messenger"
sourceSets.main.jniLibs.srcDirs = ['./jni/']
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
}
}
dexOptions {
jumboMode = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
signingConfigs {
debug {
storeFile file("config/release.keystore")
storePassword 'xxx'
keyAlias 'release'
keyPassword 'xxx'
v2SigningEnabled false
}
release {
storeFile file("config/release.keystore")
storePassword 'xxx'
keyAlias 'release'
keyPassword 'xxx'
v2SigningEnabled false
}
}
buildTypes {
debug {
debuggable true
jniDebuggable true
//signingConfig signingConfigs.debug
//applicationIdSuffix ".beta"
}
release {
debuggable false
jniDebuggable false
signingConfig signingConfigs.release
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
foss {
debuggable false
jniDebuggable false
signingConfig signingConfigs.release
}
}
defaultConfig.versionCode = 1043
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest.xml'
}
sourceSets.foss {
manifest.srcFile 'config/foss/AndroidManifest.xml'
}
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
versionCode = 2
}
armv7 {
ndk {
abiFilter "armeabi-v7a"
}
versionCode = 1
}
x86_SDK23 {
ndk {
abiFilter "x86"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
versionCode = 4
}
armv7_SDK23 {
ndk {
abiFilter "armeabi-v7a"
}
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
minSdkVersion 23
versionCode = 3
}
fat {
sourceSets.debug {
manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml'
}
sourceSets.release {
manifest.srcFile 'config/release/AndroidManifest_SDK23.xml'
}
versionCode = 5
}
}
applicationVariants.all { variant ->
def abiVersion = variant.productFlavors.get(0).versionCode
variant.mergedFlavor.versionCode = defaultConfig.versionCode * 10 + abiVersion
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionName "4.2.1"
manifestPlaceholders = [HOCKEYAPP_APP_ID: "3cbcfb69d1ce445ea2d465b3d801c534"]
externalNativeBuild {
ndkBuild {
arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-14"
abiFilters "armeabi-v7a", "x86"
}
}
}
}
apply plugin: 'com.google.gms.google-services'
问题在这里
ConnectionsManager.native_setJava(Build.VERSION.SDK_INT == 14 || Build.VERSION.SDK_INT == 15);
答案 0 :(得分:1)
我终于解决了这个问题,在逐个查看jni cpp文件之后,我发现包名仍然在org.telegram.messenger或org / telegram / messenger中 - 它不会更新到我的包中。我不确定这是Android Studio中的错误,还是源代码问题。之后我手动更改了NativeLoader.cpp,SqliteWrapper.cpp,TgNetWrapper.cpp video.c的包,然后按照此链接https://stackoverflow.com/a/34323758/7531970开始构建.so文件,不要忘记使用ndk 14b并将所有内容放入细节需要。编译你的电报,它的工作原理!
答案 1 :(得分:0)
例如,您要将包名称更改为“ com.example.messanger”。您要做的就是:
1-转到build.gradle,将applicationId值更改为com.example.messanger。
2-转到google-services.json,然后将package_name值更改为com.example.messanger。
3-构建您的项目并享受:)