I'm using Android Studio 3.0.1 and I have noticed that for one of my projects (only this one) it generates .project files and a bin directory like Eclipse does (I suppose).
The project was created in AS 3.0.1 and it was not migrated from Eclipse or anything like this. It also doesn't use any fancy Gradle plugins or dependencies - just the generated ones (AppCompat + Kotlin).
Do you have any idea why it does so?
Also, when I was trying to prepare a minimal project for reproduction, I noticed that the problem disappears just by copy-pasting the whole project directory so there's probably no point in sharing it with you.
Using two project copies (let's call them original and copy) I was able to find out that when I close Android Studio and clean both copies using git clean -xfd
copy has no issues when opened - no Eclipse-like files
original still has the issue when opened (files get generated)
diff -r before opening them (so just after git clean) gives only this:
Binary files ../PWTA_Proj2/.git/index and ./.git/index differ
both of them make Android Studio show an error like this when opened:
Unsupported Modules Detected: Compilation is not supported for following modules: PWTA_Proj2. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.
Despite of the error I can build the project normally. Also I don't have any non-Gradle modules - the project is very simple and generated by AS. The only less common thing is that the project contains a few AIDL files.
Edit #1: Gradle files:
top-level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
top-level settings.gradle:
include ':app'
app module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
final appId = "com.azabost.pwta.proj2"
applicationId appId
minSdkVersion 25
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders.tspProcessName = appId + ".tsp"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Related
i'm a newbie to Android/Java development and purchased a book Java Programming for Android Developers For Dummies, 2nd Edition.
This comes with a code samples section http://users.drew.edu/bburd/Java4Android/ (chapter 02_01) I understand the book is a few years old hence so the code samples will be. However, i'm having massive problems getting the code samples to run on Android Studio 4.1.2.
I can import the project and sync the Gradle files. When I do it appears with a green tick at the bottom. Oddly it says failed next to that with the following message.
Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
Consult IDE log for more details (Help | Show Log) (1 s 443 ms)
My build.gradle file is as follows
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.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
}
Also if I try and run the project I see this screen
I've read many posts with similar issues and worked through various fixes. None seemed to work so can anyone shed any light on what's happening please? I've also downloaded android studio on 3 different PC's incase its a bug of some sort.
Thank you
I should say the files in there are very outdated, and you will have very hard time, with every project. But if you still want to build the project here are a few things you can do.
look for the file gradle-wrapper.properties and update it with this
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
Then move to project level build.gradle file (there are two one inside app directory and one on the root directory, use the root directory)
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
// 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
}
Then move to app level build.gradle and update it with this
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.allyourcode.a02_01"
minSdkVersion 15
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
testImplementation 'junit:junit:4.13.1'
}
And then sync the project and let Android studio do its magic.
As the stack traces say, you should upgrade your Gradle version. You are using an "old" book where the samples have been build with an old version of Android Studio that supports well that old version of Gradle. But 4.1 is a recent version and does not support well many old Gradle features.
I am having some issue with my android studio, I recently updated my android studio to version 3.5 and since then I having been encountering with Gradle build error.
I even went ahead and created a new project with no code and an empty activity, when sync it compile without any issue. but upon launching it on my virtual device emulator, it brings this Gradle error
C:\Users.gradle\caches\transforms-2\files-2.1\995db56542b8715d4dfc10fddfcc653d\aapt2-3.5.0-5435860-windows
Config file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
// 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
}
App's config:
[apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.loyalteams.application"
minSdkVersion 21
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 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}][1]
I was able to fix it, it was due to paint virus that was on my pc, so during Gradle runtime and build, the hijack any exe file resulting in Gradle cache build error.
As the sole aim of this malware was to affect any runnable exe file on one's desktop and at the same time reduce the size to some kb.
What I did to fix the issue was to install Malwarebytes and Rkill to fix the issue.
I hope this helps some of us being face with the same issue.
In the main configuration file build.gradle compare what lines you have for example I have these:
What was missing is that of google() in the allprojects;
==========================================================
The gradle-wrapper.properties configuration file should look like this:
Finally I found,
I try change versions and more (taked one day from me)
Do those steps:
Remove .gradle directories
Remove all *.iml files
Remove .idea files
Reopen project
Remove intellij system directory (it is contains caches)
Everyhitg work fine ;)
I have two applications where I face the same issue while trying to update project target API from 27 to 29. To do this, first I need to update Gradle plugin at least to 3.2.+.
Project is building fine with 3.1.4, but as soon as I rise Gradle plugin to:
classpath 'com.android.tools.build:gradle:3.5.1
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
(Same error with 3.2.1 and higher)
I see next RunTime exception:
Process: com.my.app, PID: 29804
java.lang.RuntimeException: Unable to instantiate application com.my.app: java.lang.ClassNotFoundException: Didn't find class "com.my.app" on path: DexPathList[[zip file "/data/app/com.my.app-Y6_GNyscecqK5BtUnp_kjQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.my.app-Y6_GNyscecqK5BtUnp_kjQ==/lib/x86, /data/app/com.my.app-Y6_GNyscecqK5BtUnp_kjQ==/base.apk!/lib/x86, /system/lib]]
A problem that :app module source code is not compiled at all
(I can create manual compilation error and run will be still successful)
The same in both application.
What I tired:
I checked generated DEX files in the APK, source code is not there;
I create a new project with 3.5.1 plugin - it works fine;
Tried to delete gradle and .idea folders;
Tried to to clean and invalidate cache
Migrated project to AndroidX;
Added multiDexEnabled true - it was working without it before, anyway;
Copied dependencies to a new Project - works fine;
Added: to gradle.properties android.useAndroidX=true android.enableJetifier=true
My build files:
TOP level
buildscript {
ext.kotlin_version = '1.3.41'
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:6.0.0"
classpath 'com.google.gms:google-services:4.3.2'
classpath 'io.fabric.tools:gradle:1.31.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Application:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.my.app"
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "1.01"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
}
ext.anko_version='0.10.5'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.preference:preference:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation 'com.facebook.fresco:fresco:1.2.0'
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.0'
implementation "org.jetbrains.anko:anko-sdk21:$anko_version"
implementation "org.jetbrains.anko:anko-appcompat-v7:$anko_version"
implementation "org.jetbrains.anko:anko-constraint-layout:$anko_version"
implementation "org.jetbrains.anko:anko-recyclerview-v7:$anko_version"
implementation "org.jetbrains.anko:anko-recyclerview-v7-coroutines:$anko_version"
implementation "org.jetbrains.anko:anko-cardview-v7:$anko_version"
implementation 'com.r0adkll:slidableactivity:2.0.6'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-support-fragment:1.6.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
kapt "io.realm:realm-annotations-processor:5.9.0"
}
apply plugin: 'com.google.gms.google-services'
Note: another project has different set of dependencies still face the same issue
Why source code is not added to APK after migration to newer Gradle while working fine on the old one?
Update 1
Problem appear as soon as I update project to Gradle 3.2+
Update 2
Build folder doesn't contain class folder and class files
Update 3
Source code from :app module doesn't compile even tho it is in the settings.gradle file; I can create build error in any .java file and run will be executed successfully
I found an issue:
One of my packages name vas cvs - seems it is after Gradle 3.2.+ it is reserved word.
After the new update of Android Studio (3.3.0) I'm getting error from Gradle sync saying "ERROR: Cause: invalid type code: 68". Even in project, that have been created before the update and hasn't changed at all.
I've tried to reinstall Android Studio, which hasn't helped either, so there has to be something incompatible with my project, but it doesn't say what and why.
App gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "cz.cubeit.cubeit"
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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
ext.anko_version='0.10.7'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I had the same problem. I was working on a project on two PCs: one at my office and one at home. In my office, after the AS 3.3 update, everything was fine but at home, after the same steps that I did at the office, the Error code 68 came out.
After a couple of hours, I figured out how to solve it.
Android Studio 3.3 has the " Only sync the active variant" option enabled by default in Settings>Experimental. Disabling this feature resolved the problem. But reactivating the feature the same error shows up, even after a successful Gradle sync. So I think this isn't a complete solution, but at least now I can work.
I had the same issu with IntelliJ 2019.1, Untick this option works for me.
Alter path JDK location to .....\Android Studio\jre
I got a similar message ("invalid type code: E5") and resolved it by first building from the command line, which revealed it was a Firebase libs version conflict, and then switching to use firebase-bom instead of manually specifying each version.
I had the same error (6C) during a LinkedIn Learning course, I managed to solve it through the following steps
Updating Kotlin in project-level build.gradle file
Update gradle build version in project-level build.gradle file.
Open Project Structure and using the Suggestions tab, update all modules to the latest version.
Update the compileSdkVersion & targetSdkVersion to latest.
I created Android App with some gradle dependencies. Now I want to create from this project *.jar (without resources and add them separately) file or *.aar file.
I tried to create new library project (with build.xml), copied my *.java and res files and run ant jar, I'm fixing problem one by one. Is there any better solution to do this?
You need to make two modules. The first module would be the jar. This should be POJOs (Plain Old Java Object) and nothing Android. The second module would be the aar. This could depend on your first project but add on the Android specific code / resources.
Then your project (MyApp) structure would look like this
MyApp/
MyApp/build.gradle
MyApp/settings.gradle
MyApp/PoJoProject/
MyApp/PoJoProject/build.gradle
MyApp/AndroidProject/
MyApp/AndroidProject/build.gradle
Then your settings.gradle file would look something like this:
include ':PoJoProject', ':AndroidProject'
Now in the modules
In MyApp/PoJoProject/build.gradle you will want to apply the java plugin. This module will build to the desired jar format that can be ran anywhere on the normal JVM.
plugins {
id 'java'
}
version '1.00'
group 'com.example.multimodule.gradle'
repositories {
jcenter()
}
dependencies {
compile 'com.google.code.gson:gson:2.5'
testCompile 'junit:junit:4.12'
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
In the MyApp/AndroidProject/build.gradle you want to apply the android plugin. This module will build to the desired aar format and can only be used as an Android dependency.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}
apply plugin: 'com.android.application'
// version could be different from app version if needed
// `version` & `group` could also be in the top level build.gradle
version '1.00'
group 'com.example.multimodule.gradle'
repositories {
jcenter()
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.multiproject.gradle.android"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
}
dependencies {
// let the android `aar` project use code from the `jar` project
compile project(':PoJoProject')
testCompile 'junit:junit:4.12'
}