问题
I have problems formatting the post. Can someone please edit the post accordingly. Your help is much appreciated.
Also found a similar problem question - here
I am trying to integrate MonkeyTalk and Android Studio. I am following this link. When i try to sync build.gradle file in app folder, i get the following error:
Error:(37, 0) Gradle DSL method not found: 'monkeytalkCompile()'
Possible causes:<ul><li>The project 'MonkeyTalkTest' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>
Here is what i have done till now:(as steps from the link above)
Steps:
I already have a working android studio project(example) and download MonkeyTalkIDEProfessional from the website.
Created folder 'monkey-libs' inside 'app' folder and added 'monkeytalk-agent-2.0.10.jar' file to that directory.
Added the following to build.gradle file inside the 'app' folder.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5'
}
}Added the following line to build.gradle inside 'app' folder:
apply plugin: 'android-aspectj'
Again added the following code to build.gradle inside 'app' folder:
dependencies {
compile fileTree(dir: 'libs', include: ['.jar'])
monkeytalkCompile fileTree(dir: 'monkey-libs', include: ['.jar'])
}Created a folder 'monkeytalk' in 'src' folder and added AndroidManifest.xml file to it with following code:
<uses-permission android:name="android.permission.GET_TASKS"/> <uses-permission android:name="android.permission.INTERNET"/>
At this point i am trying to sync build.gradle file and i get the error mentioned earlier.
How can i get past this error?
EDIT:
build.gradle file: in app folder
apply plugin: 'com.android.application'
apply plugin: 'android-aspectj'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5'
}
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "examplepackage.com.monkeytalktest"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
monkeytalkCompile fileTree(dir: 'monkey-libs')
}
EDIT 2:
Top-level build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Project structure:
EDIT 3:
I changed the build.gradle file in 'app' folder as below, following this link. The sync works fine now. When i try to do ./gradlew clean installMonkeyTalk, i get the error in the image below.
build.gradle file
apply plugin: 'com.android.application'
apply plugin: 'android-aspectj'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.uphyca.gradle:gradle-android-aspectj-plugin:0.9.5'
}
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "examplepackage.com.monkeytalktest"
minSdkVersion 10
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
monkeytalk.initWith(buildTypes.debug)
monkeytalk {
applicationIdSuffix ".monkey"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
//monkeytalkCompile fileTree(dir: 'monkey-libs')
monkeytalkCompile(files("monkey-libs/monkeytalk-agent-2.0.10.jar"))
}
Now, i get the following error:
回答1:
I also faced same issue and used different AspectJ plugin instead of uphyca. different AspectJ plugin found at: https://github.com/leolin310148/GradleAndroidAspectJPlugin
Its Uses in build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.+'
classpath 'me.leolin:android-aspectj-plugin:1.0.7'
}
}
apply plugin: 'com.android.application'
apply plugin: 'me.leolin.gradle-android-aspectj'
Update your build.gradle file to try this solution and let me know if it works. As it worked for me.
All the best !!
来源:https://stackoverflow.com/questions/31874514/android-studio-monkeytalk-integration-issues