My Firebase Authentication Dependency Issue - android-studio

I added this line of code to my android Manifest in trying to add the Firebase Authentication Dependency:
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
}
apply plugin: 'com.google.gms.google-services'
And this is what the error I keep seeing when I sync the Gradle:
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'ng.org.fafic.fafic'
How do I resolve this error, please?
Now, when I leave my gradle to be like this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.google.firebase:firebase-auth:9.4.0'
}
My project will compile without any error. It will even allow me to use the Firebase classes for authentication. But when I try to run the app, the app crashes and I am left with this error:
Process: ng.org.fafic.fafic, PID: 24478
java.lang.RuntimeException: Unable to start activity ComponentInfo{ng.org.fafic.fafic/ng.org.fafic.fafic.RegisterActivity}: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at ng.org.fafic.fafic.RegisterActivity.onCreate(RegisterActivity.java:35)
at android.app.Activity.performCreate(Activity.java:6374)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 
at android.app.ActivityThread.access$900(ActivityThread.java:181) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:145) 
at android.app.ActivityThread.main(ActivityThread.java:6145) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 

> No matching client found for package name 'ng.org.fafic.fafic'
This error happens when the google-services.json is missing in your build.
Also check if the package_name in the google-services.json has a correct value according to your package name.
{
"project_info": {
},
"client": [
{
"client_info": {
"android_client_info": {
"package_name": "xxxxxxxxxx"
}
...
}

As i've seen from your replies with #Gabriele, Please check with me as the following.
First, Check if you've already downloaded the SDK for using Google Play Services/Firebase .
After checking, you need to add Google play services lib in your build.gradle app's level, and the firstbase, for me i used the messaging one too :
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.firebase:firebase-core:9.2.1'
And in the last line ( out of all brackets {} ), you need to add this :
apply plugin: 'com.google.gms.google-services'
Now, in your build.gradle Project's level, you need to add this inside 'dependencies' brackets
classpath 'com.google.gms:google-services:3.0.0'
the most important piece is your json file, download the json file and navigate to your project/your-app folder and paste it there, your app folder is the folder that contain files/folders like src/libs/build etc ..

Related

bootJar fails after upgrading to Gradle v7.6 (project is already evaluated)

I've updated Gradle to v7.6 and now the task bootJar does not work longer.
This is what I have configured in the past and what was working:
bootJar {
mainClass.set("com.dwiner.app.MainApplication")
from("$appDir/dist/angular/browser") {
into 'static'
}
}
bootJar.dependsOn 'npm_run_buildprod'
It seems that the dependsOn has some troubles now, as it the build keeps crashing with the following message:
org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task ':bootJar'.
...
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':npm_run_buildprod'.
...
Caused by: org.gradle.api.tasks.TaskInstantiationException: Could not create task of type 'NpmTask'.
...
Caused by: org.gradle.api.InvalidUserCodeException: Cannot run Project.afterEvaluate(Closure) when the project is already evaluated.
Update:
It seems that the issue occurs when executing npm_run_buildprod and is not dependent on the dependsOn config.
Any help is appreciated.

Updated Android Studio - many errors now

I was loading an old project into Android Studio. Android Studio asked to update which I allowed.
However - now I get error
build failed 10s 30ms Run build 9s 822ms Load build 10ms Configure
build 413ms Calculate task graph 566ms Run tasks 8s 826ms null
C:/Users/my
name/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-alpha1.aar/24c78a15e89c609bfeae2b7928d5d678/res/values-v26/values-v26.xml
C:/Users/my
name/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-alpha1.aar/24c78a15e89c609bfeae2b7928d5d678/res/values-v28/values-v28.xml
W:/android-studio-projects/sharedid C:/Users/my
name/.gradle/caches/transforms-1/files-1.1/appcompat-v7-28.0.0-alpha1.aar/24c78a15e89c609bfeae2b7928d5d678/res/values/values.xml null failed linking references.
"Run tasks" log is
org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':app:processDebugResources'. at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at
org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at
org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
at
org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at
org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
at
org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
at
org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
at
org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at
org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at
org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at
org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at
org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at
...
In my
W:\android-studio-projects\sharedid\app\src\main\AndroidManifest.xml
file I have
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="25"
/>
...
In my
W:\android-studio-projects\sharedid\app\build.gradle
file I have
compileSdkVersion 25
and
dependencies {
api 'com.google.android.gms:play-services-maps:+'
api 'com.google.android.gms:play-services-location:+'
api 'com.android.support:appcompat-v7:+'
api 'com.github.PhilJay:MPAndroidChart:v2.0.8'
}
also tried
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-maps:+'
implementation 'com.google.android.gms:play-services-location:+'
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.github.PhilJay:MPAndroidChart:v2.0.8'
}
here is the whole file
android {
defaultConfig {
applicationId "com.example.customer.app"
}
signingConfigs {
release {
}
}
compileSdkVersion 25
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
api 'com.google.android.gms:play-services-maps:+'
api 'com.google.android.gms:play-services-location:+'
api 'com.android.support:appcompat-v7:+'
api 'com.github.PhilJay:MPAndroidChart:v2.0.8'
}
...
My
W:\android-studio-projects\sharedid\build.gradle
Looks like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
...
I am but lost on solving the Android Issues... Seems not to originate from my code but appcompat. Anyhow way to flush/fix this?
...
UPDATE 23rd April: I have made the following fixes
In W:\android-studio-projects\sharedid\build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:+'
}
In W:\android-studio-projects\sharedid\app\build.gradle
defaultConfig {
applicationId "com.example.company.app"
minSdkVersion 14
compileSdkVersion 25
}
This resulted in a new set of errors - but I feel it is progress:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task
':app:processDebugResources'. at
...
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745) Caused by:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource
linking failed Output:
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:3:
warn: generated id 'android:id/background' for external package
'android'.
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:5:
warn: generated id 'android:id/progress' for external package
'android'.
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:4:
warn: generated id 'android:id/secondaryProgress' for external package
'android'.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml:7:
error: resource android:attr/colorError not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml:11:
error: resource android:attr/colorError not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml:15:
error: style attribute 'android:attr/keyboardNavigationCluster' not
found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7:
error: resource android:attr/dialogCornerRadius not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11:
error: resource android:attr/dialogCornerRadius not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/fontStyle not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/font not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/fontWeight not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/fontVariationSettings not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/ttcIndex not found. error: failed linking
references.
Command:
C:\Users\%Username%.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-alpha11-4662957-windows.jar\fc4f56a13b0b656fb51bcc296aa62bd7\aapt2-3.2.0-alpha11-4662957-windows\aapt2.exe
link -I\
D:\Java-Android-SDK\platforms\android-25\android.jar\
--manifest\
W:\android-studio-projects\sharedid\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
W:\android-studio-projects\sharedid\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
#W:\android-studio-projects\sharedid\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
W:\android-studio-projects\sharedid\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.example.company.app\
-0\
apk\
--output-text-symbols\
W:\android-studio-projects\sharedid\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors Daemon: AAPT2 aapt2-3.2.0-alpha11-4662957-windows Daemon #0 Output:
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:3:
AAPT: warn: generated id 'android:id/background' for external package
'android'.
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:5:
AAPT: warn: generated id 'android:id/progress' for external package
'android'.
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:4:
AAPT: warn: generated id 'android:id/secondaryProgress' for external
package 'android'.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values-v26\values-v26.xml:9:5-12:13:
AAPT: error: resource android:attr/colorError not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values-v26\values-v26.xml:13:5-16:13:
AAPT: error: resource android:attr/colorError not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values-v26\values-v26.xml:17:5-93:
AAPT: error: style attribute 'android:attr/keyboardNavigationCluster'
not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values-v28\values-v28.xml:9:5-12:13:
AAPT: error: resource android:attr/dialogCornerRadius not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11:
AAPT: error: resource android:attr/dialogCornerRadius not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values\values.xml:148:5-153:84:
AAPT: error: resource android:attr/fontStyle not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values\values.xml:148:5-153:84:
AAPT: error: resource android:attr/font not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values\values.xml:148:5-153:84:
AAPT: error: resource android:attr/fontWeight not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values\values.xml:148:5-153:84:
AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0-alpha1.aar\19b5707f382b2fef8a056030a0107fe4\res\values\values.xml:148:5-153:84:
AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references. Command: C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-alpha11-4662957-windows.jar\fc4f56a13b0b656fb51bcc296aa62bd7\aapt2-3.2.0-alpha11-4662957-windows\aapt2.exe
link -I\
D:\Java-Android-SDK\platforms\android-25\android.jar\
--manifest\
W:\android-studio-projects\sharedid\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
W:\android-studio-projects\sharedid\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
#W:\android-studio-projects\sharedid\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
W:\android-studio-projects\sharedid\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.example.company.app\
-0\
apk\
--output-text-symbols\
W:\android-studio-projects\sharedid\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors Daemon: AAPT2 aapt2-3.2.0-alpha11-4662957-windows Daemon #0 at
com.android.build.gradle.internal.res.Aapt2ErrorUtils.rewriteException(Aapt2ErrorUtils.kt:97)
at
com.android.build.gradle.internal.res.Aapt2ErrorUtils.rewriteLinkException(Aapt2ErrorUtils.kt:73)
at
com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:519)
at
com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.doFullTaskAction(LinkApplicationAndroidResourcesTask.java:269)
at
com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497) at
org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at
org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
at
org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
at
org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at
org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
at
org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
... 33 more Caused by:
com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource
linking failed Output:
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:3:
warn: generated id 'android:id/background' for external package
'android'.
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:5:
warn: generated id 'android:id/progress' for external package
'android'.
W:\android-studio-projects\sharedid\app\src\main\res\drawable\layerlist_micratingstars.xml:4:
warn: generated id 'android:id/secondaryProgress' for external package
'android'.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml:7:
error: resource android:attr/colorError not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml:11:
error: resource android:attr/colorError not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v26\values-v26.xml:15:
error: style attribute 'android:attr/keyboardNavigationCluster' not
found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:7:
error: resource android:attr/dialogCornerRadius not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11:
error: resource android:attr/dialogCornerRadius not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/fontStyle not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/font not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/fontWeight not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/fontVariationSettings not found.
W:\android-studio-projects\sharedid\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:235:
error: resource android:attr/ttcIndex not found. error: failed linking
references.
Command:
C:\Users\%UserName%.gradle\caches\transforms-1\files-1.1\aapt2-3.2.0-alpha11-4662957-windows.jar\fc4f56a13b0b656fb51bcc296aa62bd7\aapt2-3.2.0-alpha11-4662957-windows\aapt2.exe
link -I\
D:\Java-Android-SDK\platforms\android-25\android.jar\
--manifest\
W:\android-studio-projects\sharedid\app\build\intermediates\merged_manifests\debug\processDebugManifest\merged\AndroidManifest.xml\
-o\
W:\android-studio-projects\sharedid\app\build\intermediates\processed_res\debug\processDebugResources\out\resources-debug.ap_\
-R\
#W:\android-studio-projects\sharedid\app\build\intermediates\incremental\processDebugResources\resources-list-for-resources-debug.ap_.txt\
--auto-add-overlay\
--java\
W:\android-studio-projects\sharedid\app\build\generated\not_namespaced_r_class_sources\debug\processDebugResources\r\
--custom-package\
com.example.company.app\
-0\
apk\
--output-text-symbols\
W:\android-studio-projects\sharedid\app\build\intermediates\symbols\debug\R.txt\
--no-version-vectors Daemon: AAPT2 aapt2-3.2.0-alpha11-4662957-windows Daemon #0 at
com.android.builder.internal.aapt.v2.Aapt2DaemonImpl.doLink(Aapt2DaemonImpl.kt:177)
at
com.android.builder.internal.aapt.v2.Aapt2Daemon.link(Aapt2Daemon.kt:103)
at
com.android.builder.internal.aapt.v2.Aapt2DaemonManager$LeasedAaptDaemon.link(Aapt2DaemonManager.kt:176)
at
com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:811)
at
com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask.invokeAaptForSplit(LinkApplicationAndroidResourcesTask.java:517)
... 50 more
W:\android-studio-projects\sharedid\app\src\main\AndroidManifest.xml
---> You don't need add
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="25"
/>
W:\android-studio-projects\sharedid\app\build.gradle
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.customer.app"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
signingConfig signingConfigs.release
}
}
repositories {
maven { url "https://jitpack.io" }
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.github.PhilJay:MPAndroidChart:v2.0.8'
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'
}
W:\android-studio-projects\sharedid\build.gradle
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You can try it.
In build.graddle(app)
try changing dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:25.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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'
}
GoTO File>Project Structure(ctrl+ALT+Shift+S)
Click second button(Project) and change grade version to 4.4
Remove the gradle from the project and let android studio make one
You can solve the issue by updating the compileSdk version and build gradle of the app.
First update the build tool version of the app to 3.1.1
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
}
Second change the compileSdkVersion version of the app.Two ways to update compileSdkVersion is:
1.Specify the buildToolVersion
defaultConfig {
applicationId "com.robosoft.sampleproject"
minSdkVersion 14
compileSdkVersion 25
buildToolsVersion '26.0.2'
}
2.If you dont specify build tool version increase the compilSdkVersion to 26 for gradle 3.1.1
defaultConfig {
applicationId "com.robosoft.sampleproject"
minSdkVersion 14
compileSdkVersion 25
}
When you update Android Studio, it always ask to update your gradle version.
If you allow to update the gradle version, Your whole build files need to update like Api's and target version Which is difficult to track.
What you can do is first re import as new project and don't allow upgrade the gradle version and try to compile then if it is compiled successfully then update your gradle version related to new Android Studio.
Although this already has an answer, this didn't work for me. For lot's of developers who might still facing this issue and are unable fix by any of the above mentioned work around. Please see, what worked for me.
I noticed that in gradle.properties file there are 2 new lines,
android.useAndroidX=true
android.enableJetifier=true
Commenting these 2 in the gradle.properties made all my issues go away, and a successful build.
I hope this helps to some of the developers finding the resolution.

Jhipster gradle build failde

When running jhipster from command line I get the following error, I am using jhipster latest version (v3.12.2) on windows machine. It seems there is an issue with gradle build.
gradlew.bat bootRun
:cleanResources
:bootBuildInfo
:bower
:nodeSetup SKIPPED
:gulpConstantDev
[15:59:03] Using gulpfile C:\dev\test\gulpfile.js
[15:59:03] Starting 'ngconstant:dev'...
[15:59:03] Finished 'ngconstant:dev' after 23 ms
:processResources
:compileJava
:classes
:findMainClass
:pathingJar
:bootRun
java.lang.NoClassDefFoundError: org/springframework/core/env/Environment
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.springframework.core.env.Environment
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" :bootRun FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':bootRun'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 15.498 secs
Using Maven works.
Regards
Yes, there is a gradle issue in this version, which produces this error if gradle cache path contains spaces. I suggest you permanently remove gradle cache to a path without spaces: Set Gradle Cache Directory?
If you need a temporary quick fix, like me, you can patch this using a dirty approach to fix the JHipster classpath. Suppose your Windows user name is "Your Name". Then it will be a part of the path string and you will need to replace it with "yourna~1" (it is the 8-chars equivalent for Windows long name directories, i.e. first 6 chars of the directory name lowercase without spaces + "~1"). You can patch it in your build.gradle, line 55 and the issue is gone:
attributes 'Class-Path': configurations.runtime.files.collect {
it.toURL().toString().replaceFirst(/file:\/+/, '/').replace("Your Name", "yourna~1")
}.join(' ')

Gradle: replace tokens with project properties

I have resource file with some tokens that need to be replaced with file paths using the java plugin task 'processResources'. Does gradle provide a way in which, the token value is an expression?
1) src/resources/config.properties file has a token:
SRC_ROOT_DIR = #SRC_ROOT_DIR#
2) build.gradle file contains the following:
processResources{
filter ReplaceTokens, tokens:[SRC_ROOT_DIR: project.projectDir]
}
This throws an exception saying : could not copy file '..src\resources\config.properties' to '..build\resources\main\config.properties'
Running your snippet with --stacktrace gave me:
...
Caused by: org.gradle.api.GradleException: Could not copy file
'C:\bss\zz\src\main\resources\config.properties'
to 'C:\bss\zz\build\resources\main\config.properties'.
...
Caused by: java.lang.ClassCastException:
java.io.File cannot be cast to java.lang.String
...
Changing project.projectDir to project.projectDir.name (or path) solved it:
filter ReplaceTokens, tokens:[SRC_ROOT_DIR: project.projectDir.path]

get archetype catalog failed(can't load Ahcwagon)-m2e-0.12.1

I'm trying to use m2eclipse api to import projects by archetype.
my code is here:
RemoteCatalogFactory remoteCatalogFactory = new RemoteCatalogFactory("http:/server1/archetype-catalog.xml", null, true);
ArchetypeCatalog catalog = remoteCatalogFactory.getArchetypeCatalog();
List<Archetype> archetypes = catalog.getArchetypes();
for (Archetype archetype : archetypes){
System.out.println(archetype.getArtifactId());
}
m2eclipse version is:0.12.1.
Got below exception:
1) Error injecting: org.sonatype.maven.wagon.AhcWagon
at ClassRealm[plexus.core, parent: null]
while locating org.apache.maven.wagon.Wagon annotated with #com.google.inject.name.Named(value=http)
1 error
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:958)
at com.google.inject.Scopes$1$1.get(Scopes.java:59)
at org.sonatype.guice.bean.locators.LazyQualifiedBean.getValue(LazyQualifiedBean.java:66)
at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:54)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:247)
... 38 more
Caused by: java.lang.TypeNotPresentException: Type org.sonatype.maven.wagon.AhcWagon not present
at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:94)
at org.sonatype.guice.bean.reflect.NamedClass.load(NamedClass.java:46)
at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:48)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:949)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:995)
at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:945)
... 42 more
Caused by: java.lang.ClassNotFoundException: org.sonatype.maven.wagon.AhcWagon
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:90)
During debug, I found bundleloader is using org.maven.ide.eclipse's bundle classloader to load AhcWagon class.
because maven embedder bundle haven't export AhcWagon's package, so can't load it.
But my question is: caller(plexus-classworlds.jar) is in maven embedder bundle and AhcWagon(in wagon-ahc.jar) is in the same bundle. Why not use maven embedder's bundle loader to load AhcWagon?
Am I something wrong to use this API?
That's great! If there is any sample code.
Regards
Simon
m2eclipse0.12.1's bug, need to export org.sonatype.maven.wagon in manifest.

Resources