Error:(22, 0) Could not find method android() for arguments - android

here's my gradle file
I am getting this error
Error:(22, 0) Could not find method android() for arguments
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
defaultConfig {
minSdkVersion 26
targetSdkVersion 26
}
productFlavors {
}
}
dependencies {
}

You need to apply a plugin to your build.gradle file. Only then you will be able to use the android block. Add any of these two lines at the top of your build.gradle file:
Application : apply plugin: 'com.android.application'
Library : apply plugin: 'com.android.library'

Your App Gradle should look like something like this
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.armenhovhannisyan.backpaper.backpaper"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.0-beta1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
}

Related

What should be the gradle dependencies for compileSDK versio 28 in android studio 3.2.1

Here is the gradle code. It is unable to sync everytime. I'm really stuck here. Please help me. Thank you in advance.
The error is Failed to resolve: and then all the lines between the dependencies { }
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "global.alyssum.charcha"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'androidx.appcompat:appcompat:1.0.0-alpha1'
compile 'androidx.constraintlayout:constraintlayout:1.1.2'
compile 'com.google.android.material:material:1.0.0-alpha1'
testCompile 'junit:junit:4.12'
androidTestCompile 'androidx.test:runner:1.1.0-alpha3'
androidTestCompile 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
}
The Top-level build file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The module level build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "global.alyssum.charcha"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
staging {
signingConfig signingConfigs.debug
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

:app:transformClassesWithMultidexlistForDebug task failed

com.android.build.api.transform.TransformException :
Error while generating the main dex list.
com.android.tools.r8.errors.CompilationError:
Program type already present: com.xyja.bcclalib.BuildConfig
I have try these ways:
build clean my module
clean project
delete .gradle && build && .idea && [module]build
then rebuild my project
but I can't solved it. Anyone who can help me solve this? Thx.
This is my build.gradle(app).
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.xyja.bcclalib"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories{
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation project(':BcClaLibirary')
implementation 'com.android.support:multidex:1.0.3'
}
And this is part of my build.gradle(BcClaLibirary).
apply plugin: 'com.android.library'
android {
...
}
dependencies {
implementation files('libs/bcprov-jdk15on-157.jar')
implementation files('libs/ksoap2-android-assembly-3.6.0-jar-with-dependencies.jar')
implementation files('libs/sun.misc.BASE64Decoder.jar')
implementation (name: 'ESecurityLib-release', ext: 'aar')
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
apply from: './nexus_maven.gradle'
Try this:
//app
repositories{
flatDir {
dirs 'libs'
dirs.project(':BcClaLibirary').files('libs')
//or you can use this way
//dirs 'libs', '../BcClaLibirary/libs'
}
}

No virtual method com_polidea_rxandroidble_internal_radio_RxBleRadioImpl$$Lambda$1_lambda$new$0()V

I am new in Android Developement and I try to implement Bluetooth LE features on my app.
I have some difficulties to run my android project with RXAndroidBLE.
This library use lambda and I am not able to make it run.
I have updated my gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.maxime.applicationtest"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile "com.polidea.rxandroidble:rxandroidble:1.1.0"
}
When I try to run the following code in my MainActivity, an error is displayed:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RxBleClient rxBleClient = RxBleClient.create(this);
Subscription scanSubscription = rxBleClient.scanBleDevices()
.subscribe(
rxBleScanResult -> {
// Process scan result here.
Log.e("DEVICE", rxBleScanResult.getBleDevice().getName());
},
throwable -> {
// Handle an error here.
}
);
// When done, just unsubscribe.
scanSubscription.unsubscribe();
}
FATAL EXCEPTION: Thread-4847
Process: com.example.maxime.applicationtest, PID: 27342
java.lang.NoSuchMethodError: No virtual method com_polidea_rxandroidble_internal_radio_RxBleRadioImpl$$Lambda$1_lambda$new$0()V in class Lcom/polidea/rxandroidble/internal/radio/RxBleRadioImpl; or its super classes (declaration of 'com.polidea.rxandroidble.internal.radio.RxBleRadioImpl' appears in /data/app/com.example.maxime.applicationtest-1/base.apk)
at com.polidea.rxandroidble.internal.radio.RxBleRadioImpl$$Lambda$1.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
I've no idea why it goes wrong.
If anyone could help me it would be great.
Thanks!
I finally found a solution by removing jackOptions.
Now it works like a charm.
Had this problem too. But just removing jackOptions didn't work. Had to add retrolambda to my project. My build gradle now looks like this :
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
}
}
repositories {
mavenLocal()
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
applicationId "com.trump.islove"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile "com.polidea.rxandroidble:rxandroidble:1.1.0"
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
testCompile 'junit:junit:4.12'
}
you must write to your build.gradle file:
apply plugin: 'me.tatarka.retrolambda'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.3.1'
}
}

how does the gradle dependencies work, i can not find any function relate with it in the gradle source code

how does the gradle dependencies work, i can not find any function relate with it in the gradle source code.
please help me , I googled this but found nothing...
dependencies {
}
gradle dependencies work from build.gradle(Module:app)
buildscript {
repositories {
....
}
dependencies {
...........
}
}
apply plugin: 'com.android.application'
apply plugin: '..'
repositories {
.....
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "your pkg name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
//Here you can add your dependencies
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.google.android.gms:play-services-identity:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
........
}

Crashylitcs integration with android lib

I'm debugging stuff on a lib and was trying to integrate crashlytics on it. At first, I've followed this, and after some problems, managed to build the library without errors.
The thing is: when I try to use Fabric.with(this, new Crashlytics(), new CrashlyticsNdk()) in the app which uses that lib, it gives me an "symbol cannot be resolved".
I've tried moving this line into the lib, but all I've got was a NoClassDefFoundError.
Any suggestions?
Below, my lib gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
minSdkVersion 9
targetSdkVersion 9
versionCode 1
versionName "1.0"
}
buildTypes {
release {
}
}
productFlavors {
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/mylib.jar')
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.0#aar') {
transitive = true
}
}
and my app gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 20
buildToolsVersion '20'
defaultConfig {
applicationId 'com.test.app'
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName '1.0'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
packagingOptions {
exclude 'LICENSE.txt'
}
sourceSets {
androidTest.setRoot('src/test')
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
}
splits {
abi {
enable true
reset()
include 'armeabi'
}
}
}
repositories {
flatDir { dirs 'libs' }
}
dependencies {
compile(name: 'my-framework', ext: 'aar')
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}

Categories

Resources