从git hub运行strazzere的反仿真器时出现UnsatisfiedLinkError

时间:2019-05-22 14:02:49

标签: android android-ndk emulation ndk-build

我想向我的Android应用添加反仿真,为此,我选择了this git hub repo作为启动。我从回购中下载了zip并试图运行它,但是在加载库文件时它会引发UnsatisfiedLinkError。这是堆栈跟踪。

2019-05-22 18:55:38.808 4346-4365/diff.strazzere.anti E/AndroidRuntime: FATAL EXCEPTION: Thread-2
    Process: diff.strazzere.anti, PID: 4346
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/diff.strazzere.anti-1/base.apk"],nativeLibraryDirectories=[/data/app/diff.strazzere.anti-1/lib/arm, /system/fake-libs, /data/app/diff.strazzere.anti-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libanti.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:984)
        at java.lang.System.loadLibrary(System.java:1562)
        at diff.strazzere.anti.emulator.FindEmulator.<clinit>(FindEmulator.java:63)
        at diff.strazzere.anti.emulator.FindEmulator.hasKnownDeviceId(FindEmulator.java:159)
        at diff.strazzere.anti.MainActivity.isQEmuEnvDetected(MainActivity.java:44)
        at diff.strazzere.anti.MainActivity$1.run(MainActivity.java:29)

在这里崩溃

static {
        // This is only valid for arm
        System.loadLibrary("anti");
    }

我从build.gradle注释了这些行。取消注释这些行引发

task ndkBuild(type: Exec, description: "Task to run ndk-build") {
//    commandLine 'ndk-build'
    commandLine project.android.ndkDirectory.absolutePath + '/ndk-build', '-C', file('src/main/jni/').absolutePath
 }

tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn ndkBuild }

task cleanNative(type: Exec, description: "Task to run ndk-build clean") {
    commandLine 'ndk-build', 'clean'
}

clean.dependsOn 'cleanNative'

取消对这些行引发的评论

 18:59:56.787 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > A problem occurred starting process 'command 'C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle/ndk-build''
    18:59:56.787 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
    18:59:56.788 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
    18:59:56.788 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Run with --stacktrace option to get the stack trace.  Run with --scan to get full insights.
    18:59:56.788 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
    18:59:56.788 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
    18:59:56.788 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
    18:59:56.788 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 1s

更新使用--stacktracke

运行
Executing tasks: [:AntiEmulator:assembleDebug]


> Configure project :AntiEmulator
WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
WARNING: The specified Android SDK Build Tools version (23.0.1) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle Plugin 3.4.0.
Android SDK Build Tools 28.0.3 will be used.
To suppress this warning, remove "buildToolsVersion '23.0.1'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.

> Task :AntiEmulator:preBuild UP-TO-DATE
> Task :AntiEmulator:preDebugBuild UP-TO-DATE
> Task :AntiEmulator:compileDebugAidl NO-SOURCE
> Task :AntiEmulator:compileDebugRenderscript UP-TO-DATE
> Task :AntiEmulator:checkDebugManifest UP-TO-DATE
> Task :AntiEmulator:generateDebugBuildConfig UP-TO-DATE
> Task :AntiEmulator:prepareLintJar UP-TO-DATE
> Task :AntiEmulator:generateDebugSources UP-TO-DATE
> Task :AntiEmulator:javaPreCompileDebug UP-TO-DATE
> Task :AntiEmulator:ndkBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':AntiEmulator:ndkBuild'.
> A problem occurred starting process 'command 'C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle/ndk-build''

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':AntiEmulator:ndkBuild'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:91)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:119)
    at org.gradle.api.internal.tasks.execution.ResolvePreviousStateExecuter.execute(ResolvePreviousStateExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:93)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:45)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:94)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:67)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
    at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle/ndk-build''
    at org.gradle.process.internal.DefaultExecHandle.execExceptionFor(DefaultExecHandle.java:232)
    at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:209)
    at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:356)
    at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:86)
    at org.gradle.internal.operations.CurrentBuildOperationPreservingRunnable.run(CurrentBuildOperationPreservingRunnable.java:42)
    ... 3 more
Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle/ndk-build'
    at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27)
    at net.rubygrapefruit.platform.internal.WindowsProcessLauncher.start(WindowsProcessLauncher.java:22)
    at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36)
    at org.gradle.process.internal.ExecHandleRunner.startProcess(ExecHandleRunner.java:97)
    at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:70)
    ... 4 more
Caused by: java.io.IOException: Cannot run program "C:\Users\username\AppData\Local\Android\Sdk\ndk-bundle/ndk-build" (in directory "C:\Users\username\Downloads\anti-emulator-master\AntiEmulator"): CreateProcess error=2, The system cannot find the file specified
    at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25)
    ... 8 more
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
    ... 9 more


* Get more help at https://help.gradle.org

BUILD FAILED in 0s
7 actionable tasks: 1 executed, 6 up-to-date

0 个答案:

没有答案