Fix native lib load

This commit is contained in:
世界 2020-05-30 21:32:03 +08:00
parent 88cd325e8c
commit 688ffc3bba
No known key found for this signature in database
GPG Key ID: CD109927C34A63C4
4 changed files with 14 additions and 23 deletions

View File

@ -111,6 +111,7 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/NekoX" android:label="@string/NekoX"
android:largeHeap="true" android:largeHeap="true"
android:extractNativeLibs="true"
android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity" android:manageSpaceActivity="org.telegram.ui.ExternalActionActivity"
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:roundIcon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher"

View File

@ -5,7 +5,6 @@ import cn.hutool.core.io.resource.ResourceUtil
import org.telegram.messenger.ApplicationLoader import org.telegram.messenger.ApplicationLoader
import org.telegram.messenger.FileLog import org.telegram.messenger.FileLog
import java.io.File import java.io.File
import java.util.*
import java.util.zip.ZipFile import java.util.zip.ZipFile
object FileUtil { object FileUtil {
@ -33,7 +32,7 @@ object FileUtil {
@JvmStatic @JvmStatic
@JvmOverloads @JvmOverloads
fun delete(file: File?,filter: (File) -> Boolean = { true }) { fun delete(file: File?, filter: (File) -> Boolean = { true }) {
runCatching { runCatching {
@ -155,40 +154,30 @@ object FileUtil {
if (!execFile.isFile) { if (!execFile.isFile) {
System.loadLibrary(name) FileLog.d("Native library $execFile not found")
execFile = File(ApplicationLoader.getDataDirFixed(), "cache/lib/${execFile.name}")
if (!execFile.isFile) { if (!execFile.isFile) {
FileLog.d("Native library $execFile not found") runCatching {
execFile = File(ApplicationLoader.getDataDirFixed(), "cache/lib/${execFile.name}") saveNonAsset("lib/${Build.CPU_ABI}/${execFile.name}", execFile)
if (!execFile.isFile) { FileLog.d("lib extracted with default abi: $execFile, ${Build.CPU_ABI}")
runCatching { }.recover {
saveNonAsset("lib/${Build.CPU_ABI}/${execFile.name}", execFile) saveNonAsset("lib/${Build.CPU_ABI2}/${execFile.name}", execFile)
FileLog.d("lib extracted with default abi: $execFile, ${Build.CPU_ABI}") FileLog.d("lib extracted with abi2: $execFile, ${Build.CPU_ABI2}")
}.recover {
saveNonAsset("lib/${Build.CPU_ABI2}/${execFile.name}", execFile)
FileLog.d("lib extracted with abi2: $execFile, ${Build.CPU_ABI2}")
}
} else {
FileLog.d("lib already extracted: $name")
} }
} else { } else {
FileLog.d("lib found after load: $name") FileLog.d("lib already extracted: $name")
} }

View File

@ -7,7 +7,7 @@ buildscript {
maven { url "https://plugins.gradle.org/m2/" } maven { url "https://plugins.gradle.org/m2/" }
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.6.3' classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0'

View File

@ -20,3 +20,4 @@ org.gradle.configureondemand=false
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx4096M" -XX\:MaxPermSize\=4096m org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx4096M" -XX\:MaxPermSize\=4096m
org.gradle.parallel=true org.gradle.parallel=true
android.bundle.enableUncompressedNativeLibs=false