gpt4 book ai didi

android - 通过 Ant 检测将 MonkeyTalk 代理集成到 APK 中(在 Android Studio 之外)

转载 作者:行者123 更新时间:2023-12-02 10:07:38 27 4
gpt4 key购买 nike

我正在使用 Android Studio,并尝试使用 Ant 将 MonkeyTalk 代理集成到 APK 中。

基本上我遵循了以下步骤:

1.Download MonkeyTalk 2.0.1 Pro Beta

2.Create a new empty folder on desktop titled “example” or whatever you like

3.Copy monkeytalkpro/agents/android/monkeytalk-agent-2.0.1.jar into “example” directory

4.Copy monkeytalkpro/ant/monkeytalkpro-ant-2.0.1.beta.jar into “example” directory

5.Copy your apk file into “example” directory (named myapp.apk for this example)

6.Create a new file called build.xml in “example” directory and fill it with the following:

<target name="instru">
<mt:instrument
srcfile="myapp.apk"
destfile="myapp-post-instrumented.apk"
agent="monkeytalk-agent-2.0.1.jar"
androidsdk="/path/to/your/sdk"
androidtarget="android-21"
log="log.txt"
verbose="true" />
</target>

7.Open terminal and cd into your “example” directory

8.Issue command ant instru -lib monkeytalkpro-ant-2.0.1.beta.jar

9.The command should run and then produce a monkeytalk compatible apk in your “example” directory titled “myapp-post-instrumented.apk”

WARNING: There seems to be a bug where the instrumentation process will also place another file in your “example” directory titled “myapp-instrumented.apk”, but this file will be empty. So make sure your destination file is not titled “myapp-instrumented.apk” in your build.xml file or this empty file will overwrite your monkeytalk compatible file.

来源:http://w3facility.org/question/android-studio-and-monkeytalk/#answer-23016422

我所做的和原来的步骤有两个区别:

  1. MonkeyTalk 代理和 ant jar 的实际版本是 2.0.10,而不是 2.0.1

  2. 使用编译工具21.1.2,monkeytalkpro-ant-2.0.10.beta.jar中集成的APKTool无法提取文件。因此,我更新了 APKTool 并生成了一个新的 jar。你可以在这里找到它: https://www.dropbox.com/s/qsjaz5g15hy9i7k/monkeytalkpro-ant-2.0.10.beta.mod.jar?dl=0

但是经过此修复后,ant 无法“检测”APK。 Ant 对文件进行 dex 处理时出现问题。

感谢任何帮助和建议。

P.d.1:我尝试使用来自uphyca(v0.9.7)的aspectj的gradle android插件编译Android studio,但它不起作用。它编译了该项目,但当我尝试启动它时它崩溃了。

P.d.2:以下是一些日志:

-pre-compile:

-compile:

-post-compile:

-obfuscate:

-dex: [dex] input: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/classes [dex] input: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/monkeytalk-agent-2.0.10.jar [dex] input: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/weaved.jar [dex] Pre-Dexing /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/monkeytalk-agent-2.0.10.jar -> monkeytalk-agent-2.0.10-3ffc60da466c609b3dc28c1c7533ad15.jar [dex] Pre-Dexing /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/libs/weaved.jar -> weaved-0d60e12eb7c45a42662ee42c5398a922.jar [dx] [dx] EXCEPTION FROM SIMULATION: [dx] local 0005: invalid [dx] [dx] ...at bytecode offset 0000000b [dx] locals[0000]: Landroid/support/v7/widget/ActionMenuView; [dx] locals[0001]: Landroid/view/ViewGroup$LayoutParams; [dx] locals[0002]: [dx] locals[0003]: [dx] locals[0004]: [dx] locals[0005]: [dx] ...while working on block 000b [dx] ...while working on method generateLayoutParams:(Landroid/view/ViewGroup$LayoutParams;)Landroid/support/v7/widget/ActionMenuView$LayoutParams; [dx] ...while processing generateLayoutParams (Landroid/view/ViewGroup$LayoutParams;)Landroid/support/v7/widget/ActionMenuView$LayoutParams; [dx] ...while processing android/support/v7/widget/ActionMenuView.class [dx] [dx] 1 error; aborting

BUILD FAILED /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:892: The following error occurred while executing this line: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:894: The following error occurred while executing this line: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:906: The following error occurred while executing this line: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/build_master.xml:283: null returned: 1

Total time: 14 seconds : ERROR: Process exited with an error: 1 (Exit value: 1)

instrumented APK file was not created at: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/app-debug-debug.apk

Error instrumenting apk '/Users/monkeyTalk/app-debug.apk': instrumented APK file was not created at: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/app-debug-debug.apk

com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor$InstrumentationException: instrumented APK file was not created at: /private/var/folders/fb/xhjph6n17sl_tnc7gfs_0ny80000gp/T/tmp_AndroidInstrumentor1423638478563_1/app-debug/bin/app-debug-debug.apk at com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor.copyInstrumentedApk(AndroidInstrumentor.java:244) at com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor.beginInstrumentation(AndroidInstrumentor.java:173) at com.gorillalogic.monkeytalk.instrumentor.android.AndroidInstrumentor.instrumentApk(AndroidInstrumentor.java:130) at com.gorillalogic.monkeytalk.ant.InstrumentTask.execute(InstrumentTask.java:62) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:390) at org.apache.tools.ant.Target.performTasks(Target.java:411) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399) at org.apache.tools.ant.Project.executeTarget(Project.java:1368) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1251) at org.apache.tools.ant.Main.runBuild(Main.java:809) at org.apache.tools.ant.Main.startAnt(Main.java:217) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

这是完整的日志: https://www.dropbox.com/s/y3mo9ifgalpzf29/log.txt?dl=0

更新

这是build.gradle文件的内容。

apply plugin: 'com.android.application'
apply plugin: 'robolectric'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.jiahaoliuliu.monkeytalk"
minSdkVersion 14
targetSdkVersion 19
versionCode 52
versionName "1.9999"

multiDexEnabled true
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

monkeytalk.initWith(buildTypes.debug)
monkeytalk {
applicationIdSuffix ".monkey"
}
}

sourceSets {
androidTest {
setRoot('src/test')
}
}

dexOptions {
javaMaxHeapSize "4g"
}

lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}

dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.github.chrisbanes.photoview:library:1.2.3'
compile 'com.etsy.android.grid:library:1.0.5'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
compile 'com.google.android.gms:play-services-base:6.5.+'
compile 'com.google.android.gms:play-services-wallet:6.5.+'
compile 'com.google.android.gms:play-services-ads:6.5.+'
compile 'com.google.android.gms:play-services-maps:6.5.+'
compile 'com.google.android.gms:play-services-drive:6.5.+'
compile 'com.google.android.gms:play-services-appindexing:6.5.+'
compile 'com.google.android.gms:play-services-location:6.5.+'
compile 'com.google.android.gms:play-services-identity:6.5.+'
compile 'com.google.android.gms:play-services-plus:6.5.+'
compile 'com.android.support:multidex:1.0.0'
compile project(':Adjust')
compile project(':aFileChooser-cbccac1d1cb74a6d57d25c5ded61e4bf4fc40c91')
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.android.support:recyclerview-v7:+'

androidTestCompile 'org.robolectric:robolectric:2.4'
androidTestCompile('junit:junit:4.12')
androidTestCompile('org.mockito:mockito-core:1.10.19')
}
}


robolectric {
include '**/*Test.class'
}

最佳答案

我遇到了同样的问题,但现在我可以检测该 apk。您应该让 apk 处于 Debug模式。不要在 Android Studio 中添加任何 Monkeytalk 库依赖项。在app/AndroidManifest.xml中添加GET_TASKS权限。在版本 21 中,此 api 已弃用,因此您需要设置较低的 Targetsdkversion,例如 19。

如果您使用较低版本编译 sdk,您将能够成功检测 apk。 :)

干杯,苏曼

关于android - 通过 Ant 检测将 MonkeyTalk 代理集成到 APK 中(在 Android Studio 之外),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28451455/

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