Android studio 1.1.0 cannot setup Robolectric - android

I have used Robolectric before Android 1.1.0 but I cannot use it any more after I updated it. I Googled it and tried some solutions but none of them worked.
Here is my current settings:
project.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.github.jcandksolutions.gradle:android-unit-test:2.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
app.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "my_package_name"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'android-unit-test'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:21.0.3'
testCompile 'org.easytesting:fest:1.0.16'
testCompile 'junit:junit:4.10'
testCompile 'org.robolectric:robolectric:2.4'
testCompile 'com.squareup:fest-android:1.0.8'
}
When I try to build the project it gives me the error like below:
Error:(22) A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'android-unit-test']
> No such property: bootClasspath for class: com.android.build.gradle.AppPlugin
Of course, I have android-unit-test plugin installed and removed and reinstalled it again but no luck.
Your answer would be appreciated.

Bad news: since Android Plugin 1.1.0 the plugin com.github.jcandksolutions.gradle:android-unit-test:2.1.1 is depricated. Also see https://github.com/JCAndKSolutions/android-unit-test#deprecation-notice
Good news: You don't need anymore a plugin for robolectric. Just remove apply plugin: 'android-unit-test' and all should work like before.
Here an examples project setup https://github.com/nenick/AndroidStudioAndRobolectric

Related

google-play-services-maps:17.0.0 is not working even with default project Android Studio created

Please help me...
I want to create a project based on Google Maps. But after building gradle in Android Studio, The following error occurs:
ERROR:
Failed to resolve: com.google.android.gms:play-services-maps:17.0.0
Install Repository and sync project
Show in Project Structure dialog
Affected Modules: app
When i clicked on the 'Install Repository and ...' then this message appear:
Could not find dependency "com.google.android.gms:play-services-maps:17.0.0"
NOTE:
Gradle work online mode.
I went to Setting and Android SDK then downloaded google play services.. but it is not working for me.
I also set up a proxy.
EDIT:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
root gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
After much effort, I was able to solve the problem.
Strange as it may seem, the problem was solved by manually adjusting the proxy.
thanks all.

How to add TIKA into build.gradle using android studio?

I'm trying to put Apache Tika into my project.
But it returns error, unfortunately, I couldn't solve this problem by myself.
How can I put Apache Tika using android studio?
Error:(27, 0) Gradle DSL method not found: 'runtime()'
Possible causes:The project 'AudioTest' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test.audiotest"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
runtime 'org.apache.tika:tika-parsers:1.13'
}
this is my build.gradle module:app
// 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:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
this is my build.gradle project:AudioTest
change
runtime 'org.apache.tika:tika-parsers:1.13'
to
compile 'org.apache.tika:tika-parsers:1.13'

Adding Dagger-2 to Android Studio

I asked this question previously https://stackoverflow.com/questions/35981039/instrumentation-doesnt-inject-touch-in-rooted-device which states that instrumentation doesn't work on Lollipop and later versions. After some deep search I found that we should add Dagger-2 to be compiled with the project. I used the steps related to gradle available here: https://github.com/codepath/android_guides/wiki/Dependency-Injection-with-Dagger-2
This is my build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
This is app/build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.project.android.vecsat"
minSdkVersion 10
targetSdkVersion 19
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:19.0.0'
compile 'com.android.support:support-v4:19.0.0'
apt 'com.google.dagger:dagger-compiler:2.0.2'
compile 'com.google.dagger:dagger:2.0.2'
provided 'org.glassfish:javax.annotation:10.0-b28'
compile project(':libraries:opencv')
}
After synchronizing the project, nothing was fixed. Still instrumentation doesn't work. I found another guide here: https://github.com/kkovach/dagger/blob/update-install-gradle/README.md
But, I don't know where to place dagger jar file, and I can't figure out where is java gradle.
Can somebody please help me? What are the correct steps to add Dagger-2 to the project?

Android Studio Gradle DSL method not found: 'mavencentral()'

I am trying to use facebook SDK in my android apps, and I am starting to add maven central repository to my build.gardle. Although, I've found 2 build.gardle which belong to project and app. Here they are;
Android Studio: 1.5.1
Gradle Version: 2.8
Android Plugin Version: 1.5.0
Build.gardle (Project)
buildscript {
repositories {
jcenter()
mavencentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
}
allprojects {
repositories {
jcenter()
mavencentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Build.gardle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
}
Yet I get this following error during build;
Gradle DSL method not found: mavencentral()
I have tried;
Checking both gardle files
Removing android compile dependencies that's actually should be there
Checking android packagingOptions.exclude
Checking if there's android method in the gardle
And, I haven't tried to update my gardle or android studio, but I am just wondering whether it's really needed or I am doing something wrong with my build.gardle.
Any suggestion is appreciated. Thank you.
The Facebook SDK page is clear. Add into your project/build.gradle
repositories {
mavenCentral() //note the uppercase C
}
and into your project/app/build.gradle
dependencies {
compile 'com.facebook.android:facebook-android-sdk:4.+'
}

Errors while porting project to Android Studio?

I'm new to Android Studio, I've been using Eclipse for about 2 years. I've trying understanding these solutions.
Android gradle build Error:(9, 0) Gradle DSL method not found: 'compile()'.
Gradle DSL method not found: 'compile()'
I just can't get it to work.
Here's what it says..
Error:(17, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'clxxxii - PMv5' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper fileThe build file may be missing a Gradle plugin.
Apply Gradle plugin
and
'dependencies' cannot be applied to '(groovy.lang.Closure)' less... (⌘F1)
This inspection reports assignments with incompatible types
Here's the file where it's giving an error
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0' }
}
allprojects {
repositories {
mavenCentral()
}
}
dependencies {
apply plugin: 'announce'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.+'
}
And based on the other questions, you may need this too.
apply plugin: 'android'
android {
compileSdkVersion 17
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/FlurryAnalytics_3.3.0.jar')
compile files('libs/heyzap-ads-sdk.jar')
compile files('libs/HomeBaseSDK2.2.jar')
compile files('libs/placed-persistent-sdk-1.10.jar')
compile files('libs/revmob-6.7.0.jar')
}
Can someone help me understand what the problem is, and why it's happening?
This might not fully answer your question but maybe you can get your project running.
These dependencies dont belong in your first build.gradle file :
dependencies {
apply plugin: 'announce'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:cardview-v7:21.0.+'
}
Your dependencies in your Project build.gradle should look like this, the comment is generated by the IDE and tells you not to put your app dependencies here :
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Move them to the /app/build.gradle file, and I modified your file a little so its up to date to the currently newest version of buildTools etc. You might have to download some of them from your SDK Manager if you dont already have :
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "your.package.name"
minSdkVersion 8
targetSdkVersion 22
}
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.0.0'
compile 'com.android.support:support-v4:+'
compile files('libs/FlurryAnalytics_3.3.0.jar')
compile files('libs/heyzap-ads-sdk.jar')
compile files('libs/HomeBaseSDK2.2.jar')
compile files('libs/placed-persistent-sdk-1.10.jar')
compile files('libs/revmob-6.7.0.jar')
}

Categories

Resources