After 6h spent trying to fix this by myself, AS is driving me crazy. Everything was fine yesterday and today it can't resolve any of the support libs nor the R symbols.
I tried everthing, including all the suggested fixes I found on StackOverflow. No need to tell me to have a look a this post, I already have and none of the solutions work.
Here's what I tried so far :
rebuilding / cleaning the project (many times...),
synchronising the project with Gradle Files,
check that the support lib is up-to-date in the SDK Manager,
invalide Caches / restart AS,
delete the .idea folder and the .iml files of my project, and re-importing it in AS,
update AS from 0.8.11 to 0.9,
eventually I ended up uninstalling AS and reinstalling it from scratch
And none of this fixed my issue...
Something really weird is that I also tried to create a whole new project from scratch and to copy/paste all my classes & resources from my corrupted project to this new one. And it worked for a while (~10 min), until it eventually became corrupted the same way, without any apparent reason.
Moreover, no idea if it's relevant, but when I type "ViewPager" in AndroidStudio and hit CTRL-SPACE, it doesn't suggest me the "android.support.v4.view.ViewPager" class. But if I hit CTRL-SPACE 3 times in a row, it DOES suggest it. So I guess that means that it's able to find the support lib somewhere but not to use it?
Here's my build.gradle :
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.mathieumaree.library"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:support-v13:21.0.0'
}
Please, help me, otherwise I'm gonna break my computer soon.
Thanks in advance,
Mathieu
EDIT 1 :
I forgot to mention that this occurs only in one of my projects. The others seem to be fine (at least for now).
EDIT 2 :
I also forgot to mention that my project is composed of an application project plus a library module inside it. So here is the app's build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.mathieumaree.materialheaderviewpager"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.android.support:support-v13:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
}
The app Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathieumaree.materialheaderviewpager" >
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.mathieumaree.materialheaderviewpager.MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The library manifest :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mathieumaree.library">
<application android:allowBackup="true"
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme">
</application>
</manifest>
The main settings.gradle :
include ':app', ':library'
And the main build.gradle :
// 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:0.14.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
EDIT 3 :
After trying once more to delete all .idea folers & *.iml files and reloading my project, I noticed that AndroidStudio displayed an error at openning :
Accessing invalid virtual file:
file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21;
original:582; found:-: Accessing invalid virtual file:
file://C:/Users/Mathieu/AppData/Local/Android/android-studio1/sdk/sources/android-21;
original:582; found:-
I'm pretty sure it means it's looking for the SDK to yet another location (AppData/Local...android-21). What I don't understand is :
there's no SDK folder at this location
the SDK path indicated in the Project Structure is not this one
Any idea what all this means?
try addind this to buid.gradle
compile 'com.android.support:support-v4:21.0.0
and change build tools version to 20.0.0
Also create a whole new project and see if the same errors are still present in that project.
Try "Tools" -> "Android" -> "Sync Project with Gradle Files"
Well, still not a clue what caused this problem but it would look like I managed to get rid of it, although I had to create a new project from scratch. What I really don't understand is that I've already done this yesterday and it didn't work out.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm trying to implement my first sceneform application.
I'm following the following tutorials:
My references:
https://www.youtube.com/playlist?list=PLsOU6EOcj51cEDYpCLK_bzo4qtjOwDWfW
https://developers.google.com/ar/develop/java/quickstart
I'm using the following configurations:
mac os High Sierra - Version 10.13.6 (17G7024)
Android Studio - 3.1.3
My app's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myfirstapp.example.com.helloar"
minSdkVersion 26
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'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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'
// Provides ArFragment, and other UX resources.
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.11.0'
implementation 'com.google.ar:core:1.11.0'
// Alternatively, use ArSceneView without the UX dependency.
implementation 'com.google.ar.sceneform:core:1.11.0'
}
apply plugin: 'com.google.ar.sceneform.plugin'
sceneform.asset('sampledata/ArcticFox_Posed.obj',
'default',
'sampledata/ArcticFox_Posed.sfa',
'src/main/assets/ArcticFox_Posed')
My project's gradle 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.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.ar.sceneform:plugin:1.11.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My manifest file :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myfirstapp.example.com.helloar">
<uses-permission android:name="android.permission.CAMERA" />
<!-- "AR Required" apps must declare minSdkVersion ≥ 24 -->
<uses-sdk android:minSdkVersion="24" />
<!-- Indicates that the app requires ARCore ("AR Required"). Ensures the app is
visible only in the Google Play Store on devices that support ARCore.
-->
<uses-feature android:name="android.hardware.camera.ar" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.ar.core" android:value="required" />
</application>
</manifest>
When I right clicked on .obj file and clicked on import sceneform asset. It's throwing the adding the following to my app's gradle file
apply plugin: 'com.google.ar.sceneform.plugin'
sceneform.asset('sampledata/ArcticFox_Posed.obj',
'default',
'sampledata/ArcticFox_Posed.sfa',
'src/main/assets/ArcticFox_Posed')
Error Given:
Unable to find method 'com.android.build.gradle.api.ApplicationVariant.getMergeResourcesProvider()Lorg/gradle/api/tasks/TaskProvider;'.
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Kindly help with the fix.
I've upgraded my android studio to 3.4.2 and it's working now.
I'm trying to implement data-binding in android app. This is the link I'm following to set it up. Even after doing all the necessary implements, I'm getting the following error in gradle-build:
error: package com.example.satpracticeapp.databinding does not exist.
(This package is what I'm importing in my MainActivity.java file)
I tried this (the data-binding compiler), but it didn't work.
The problem is I've already successfully tried a hello-world app using data-binding and it works. But, when I try to implement it in an app I made a few weeks ago, I get the error I mentioned above. Searching for the solutions, I copy-pasted the gradle files from my successful hello world app to my old app - that too didn't work out.
Here is my app level build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.satpracticeapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.0'
}
And here's the buildscript of the project level build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
Here are the links to the minimal version of the three files (if it's needed)
MainActivity.java
ViewModel.java
activity_main.xml
After much hair-pulling, I couldn't figure out the solution and getting the same build error again and again.
So, as a temporary solution, I'm trying to copy-paste my classes and layouts in the working hello world project. What am I missing?
EDIT:
After a few hours of pointless searching, I went back to my code. Checked it word by word and found a typing mistake at the name of a binding variable in the xml file.
Everything works fine now!
I had the same issue, turned out to be a duplicate symbol declaration in one of my *.java classes. It's shown in the Gradle console but it was kinda hidden among the databinding errors. i had about 72 data binding errors and this duplicate symbol error was in the middle so it's easy to miss.
I have a build problem with Android Studio in a new project I've recreated. Please follow what I've done and if anyone has any idea how to proceed, do tell!
I started a new project, selecting 'Navigation Drawer Activity' as my initial start-point (could be anything I guess).
I instantly built my new 'empty' app and debugged it on a real device (a nexus 9). All runs fine.
I then added an office-file-creating library I want to use for creating xlsx files, so I added the following line to my build.gradle app file (in dependencies):
compile 'org.apache.poi:poi-ooxml:3.13'
I resync and it builds ok (within seconds). I then attempt to debug this on a real device but it doesn't build anymore (takes 10x longer to attempt build) and I get an error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_25\bin\java.exe'' finished with non-zero exit value 1
I looked this up and every place I look people are telling others to use "multiDex". I understand this applies if you are exceeding 65K methods. I guess with the POI library I might well be exceeding that. After finding no other alternative course of action I implemented multiDex by adding the following lines to my build.gradle app file:
multiDexEnabled true
compile 'com.android.support:multidex:1.0.1'
and adding the following line to my Manifest file:
android:name="android.support.multidex.MultiDexApplication"
I assume I've implemented the multiDex ok. The app builds ok but when I attempt to debug it I am met with this error (takes about 7sec to get here):
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class
No other files were tampered with. If I remove the compile POI library line from build.gradle then all is ok. I put the library back in, it fails in the same way.
I've tried to figure out how to tell it to ignore the duplicate library in xmlbeans (again other posts tell coders this is what needs to be done) but I'm not sure how to do that and if that is the best way forwards ie should I still be multiDex'ing?
It's taken me a few days on-and-off to get this far and it's my first time using Android Studio - migrating away from Eclipse because I'm fed up of not being able to build my apps for days for no good reason.
Someone who knows what this all means... help me please!
Edit: I have cleaned & rebuilt the project and also tried deleting the build files but to no avail.
Program stats:
Android Studio 1.5.1
Build #AI-141.2456560, built on December 1, 2015
JRE: 1.8.0_25-b18 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Gradle ver: 2.8
Android plugin ver 1.5.0
'build.gradle' app file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.kane.testproject"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
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.1'
compile 'com.android.support:design:23.1.1'
compile 'org.apache.poi:poi-ooxml:3.13'
compile 'com.android.support:multidex:1.0.1'
}
'AndroidManifest.xml' file
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.kane.testproject"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
Add the following lines in build.gradle(Module app)
dexOptions {
javaMaxHeapSize "2g"
}
I'm new to android studio and had somebody write an app I made which was originally used in app inventor. I followed his template and added new things. The app has a problem with the Gradle and gives me the following.
"Error:(3, 0) Plugin with id 'com.android.application' not found."
It also says that my extras Android Support Repository isn't installed however it is. and everything is up to date. I saw many things about updating the Gradle, How do I do that if the SDK manager didn't.
code is:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
defaultConfig {
applicationId "contactorganizer.introcode.or.myapplication"
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.0'
}
Sorry about not having much knowledge.
If you would like the project I can email it to you because I have absolutely no clue and would love to just build this.
Thanks for your help!
When I updated my Android Studio to the latest, I got the same problem. Here is how I solved it.
First:
Add the following code to the top of your build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Second: Find the gradle-wrapper.properties.
Change the last sentence to this:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Hope this works for you.
I have faced the problem too. The android plugin is 1.2.3. It appears when running one module task in the module directory like this way, ../graldew :module:xxx.
I eventually notice plugin 1.2.3 cannot get right context and android plugin 1.5 works well. So It will work to give it right gradle file.
../gradlew -b ../build.gradle -c ../settings.gradle :module:xxx
This is the situation for me. You can just regard it as a reference.
I'm making an app using Android Studio v0.5.9, which has a library project as a dependency. But, every time I run the project two apks having the same name and icon, are deployed to my device. The first apk(app) contains my main module, whereas, the second one is the library project itself. However, when I run the same project from Eclipse, only one apk is deployed and it works perfectly.
Here are some screenshots of the problem -
First App(My module) -
Second App(library project) -
top-level build.gradle file -
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
}
}
main module build.gradle file -
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
defaultConfig {
packageName 'com.Swap.Rooms'
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:19.0.1'
compile 'com.android.support:appcompat-v7:19.0.1'
compile 'com.android.support:appcompat-v7:19.+'
compile project(':lib')
}
library project build.gradle file -
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
packageName "com.jfeinstein.jazzyviewpager"
minSdkVersion 4
targetSdkVersion 17
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile files('libs/nineoldandroids-2.4.0.jar')
}
settings.gradle -
include ':app'
include ':lib'
Please help me to fix this. Thanks in advance!!
Maybe this will be helpful for others.
Gradle is doing manifest merge for library projects as well. So issue was to keep AndroidManifes.xml unchanged from library. It had application node for demo purposes and this node was successfully merged to main AndroidManifest.xml.
I'm going to submit issue to Google since I think it should prevent or warn about such situation.
Eugen Martynov answer is correct but i decided to reiterate what he said in layman's terms.
Go through your libraries and check their AndroidManifest.xml. One of them should have an <application> tag in it. Remove the tag and the double app problem will be solved.
The specific element in the ApplicationManifest.xml, that affects creating multiple launcher icons is the <intent-filter> containing <category android:name="android.intent.category.LAUNCHER"/>. Removing this <intent-filter> will give you control over the number of launcher icons. You can read a bit more elaborate SO answer here.
It took me time to realize where the issue was.But finaly worked out for me.
The issue is with the Manifest.xml file. It means that you have two activities set as LAUNCHER.
just remove the code simmilar to the one below from the activity that is not your LAUNCHER
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>