The code below crashes my app before it gets a chance to run:
public class MainActivity extends AppCompatActivity {
EditText txtname,txtage,txtphone,txtheight;
Button btnsave;
DatabaseReference reff;
Schedule schedule;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtname=(EditText)findViewById(R.id.txtname);
txtage=(EditText)findViewById(R.id.txtage);
txtphone=(EditText)findViewById(R.id.txtphone);
txtheight=(EditText)findViewById(R.id.txtheight);
btnsave=(Button)findViewById(R.id.btnsave);
schedule=new Schedule();
reff=FirebaseDatabase.getInstance().getReference().child("Schedule");
btnsave.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
int agea=Integer.parseInt(txtage.getText().toString().trim());
Float hit=
Float.parseFloat(txtheight.getText().toString().trim());
Long phn=Long.parseLong(txtphone.getText().toString().trim());
schedule.setName(txtname.getText().toString().trim());
schedule.setAge(agea);
schedule.setHt(hit);
schedule.setPh(phn);
reff.child("schedule1").setValue(schedule);
Toast.makeText(MainActivity.this, "Data inserted successfully",
Toast.LENGTH_LONG).show();
}
});
Toast.makeText(MainActivity.this, "Firebase connection Success",
Toast.LENGTH_LONG).show();
}
}
I am new to Firebase and not sure where I am going wrong, the code runs when my reff = firebase line is commented out so there must be a problem with the way I am referencing, but obviously, the code does nothing without the connection to the database, if anyone could help.
Logs from crash as requested:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.notihng/com.example.notihng.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.notihng. Make sure to call FirebaseApp.initializeApp(Context) first.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3081)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6806)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.notihng. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common##16.0.4:240)
at com.google.firebase.database.FirebaseDatabase.getInstance(com.google.firebase:firebase-database##16.0.6:67)
at com.example.notihng.MainActivity.onCreate(MainActivity.java:28)
at android.app.Activity.performCreate(Activity.java:7210)
at android.app.Activity.performCreate(Activity.java:7201)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1272)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2926)
... 11 more
App Gradle File:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.notihng"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-
optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-
layout:1.1.3'
implementation 'com.google.firebase:firebase-database:16.0.6'
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'
}
apply plugin: 'com.google.gms.google-services'
The crash report clearly says the problem in your code.
Make sure to call FirebaseApp.initializeApp(Context) first
You need to initialize it first before using it like the following.
FirebaseApp.initializeApp(this);
In your build.gradle file, there are two declarations of adding the following plugin.
apply plugin: 'com.google.gms.google-services'
I would like to suggest you remove the first one. Keep the one at the end of your gradle file.
Got it working guys thanks for all the help.
It was the dependencies in project gradle, when i changed them to
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.google.gms:google-services:3.0.0'
It promted me to install new sdk files.
Not sure if the default dependencies just werent working or the downloading files was the fix, but its working now anyways, thanks again.
Related
I am using the Android studio Arctic Fox version. I need to implement an automated notification app that is going to send notifications by date. I am running my apps on an actual device with the 6.0.1 android version. I have connected fcm and set up the dependencies as well. But token is not showing on logcat. Also registered the app in firebase. Any ideas why this is happening?
build:gradle(:app)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.f1"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.firebase:firebase-messaging:22.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
build:gradle(module)
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
manifest.xml
<service android:name=".MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
MyFirebaseMessagingService
public class MyFirebaseMessagingService extends FirebaseMessagingService {
#Override
public void onNewToken(#NonNull String s)
{
super.onNewToken(s);
Log.d("My token", "Refreshed Token"+s);
sendRegistrationToServer(s);
}
private void sendRegistrationToServer(String s) {
}
}
If you ran the app on the device before adding the MyFirebaseMessagingService code, it probably already generated a token then. Adding the MyFirebaseMessagingService does not generate a new token, so your onNewToken will not be called.
The two options to get the token in that case are:
Call FirebaseMessaging.getInstance().getToken() from (for example) you main activity and call the same sendRegistrationToServer there.
Delete the app and its data after you added the FirebaseMessaging.getInstance().getToken() code, and reinstall the app. Deleting the data deletes the token, so then when you run the app it will generate a new token and call your onNewToken.
I'm developing an application that allows the user to contact me by sending an email (the user only inputs the message, sender and receiver emails are both mine). I'm trying to implement this with gmail using the JavaMail API. However, I keep getting this error at the Transport.send(mimeMessage) line.
Here are the error messages:
Caused by: java.lang.VerifyError: Rejecting class com.sun.mail.handlers.text_plain that attempts to sub-type erroneous class com.sun.mail.handlers.handler_base (declaration of 'com.sun.mail.handlers.text_plain' appears in /data/app/~~T_TRkO9R_v9j4iEdr4K9Yg==/com.example.compusec-dPeAL8DtGJvU45dJpt8xxA==/base.apk)
Caused by: java.lang.VerifyError: Verifier rejected class com.sun.mail.handlers.handler_base: java.awt.datatransfer.DataFlavor[] com.sun.mail.handlers.handler_base.getTransferDataFlavors() failed to verify: java.awt.datatransfer.DataFlavor[] com.sun.mail.handlers.handler_base.getTransferDataFlavors(): [0x4] can't resolve returned type 'Unresolved Reference: java.awt.datatransfer.DataFlavor[]' or 'Reference: javax.activation.ActivationDataFlavor[]' (declaration of 'com.sun.mail.handlers.handler_base' appears in /data/app/~~T_TRkO9R_v9j4iEdr4K9Yg==/com.example.compusec-dPeAL8DtGJvU45dJpt8xxA==/base.apk)
Here is my code:
protected Void doInBackground(Void... voids) {
Properties properties = new Properties();
properties.put("mail.smtp.host", "smtp.gmail.com");
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
session = javax.mail.Session.getInstance(properties, new javax.mail.Authenticator(){
protected PasswordAuthentication getPasswordAuthentication(){
return new PasswordAuthentication("sender#gmail.com","senderpass");
}
});
session.setDebug(true);
MimeMessage mimeMessage = new MimeMessage(session);
try {
mimeMessage.setFrom(new InternetAddress("sender#gmail.com"));
mimeMessage.addRecipients(Message.RecipientType.TO, String.valueOf(new InternetAddress(email)));
mimeMessage.setSubject(subject);
mimeMessage.setText(message);
Transport.send(mimeMessage);
} catch (MessagingException e) {
e.printStackTrace();
}
return null;
}
And the gradle script:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
packagingOptions {
pickFirst 'META-INF/LICENSE.txt' // picks the JavaMail license file
}
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
jcenter()
maven {
url "https://maven.java.net/content/groups/public/"
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
compile 'com.sun.mail:android-mail:1.6.2'
compile 'com.sun.mail:android-activation:1.6.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Use this in build.gradle:
android {
...
packagingOptions {
exclude 'META-INF/NOTICE.md'
exclude 'META-INF/LICENSE.md'
}
}
dependencies {
implementation 'com.sun.mail:android-mail:1.6.6'
implementation 'com.sun.mail:android-activation:1.6.6'
...
}
credit to last few comments on this issue
I am having the same issue. What I can tell you is that if you target Android 10 and lower (SDK 29 or lower) it works fine. I have been using it for years. However, as soon as I target Android 11 (SDK 30) then I get this error. My guess is com.sun.mail dependencies need to be updated. I'm using the latest 1.6.5 and still doesn't work. So I suggest targeting SDK 29 for now and see if that helps.
My answer here, that is in-line with other answers (as that answer explains), does provide a solution (I'll skip to the content here, details can be read there);
The issue:
API level 30 adds a new (verifier) feature that verifies that all referenced code actually exists - or fails a build.
To resolve:
If you were providing the libraries manually via /app/libs/mail.jar, /app/libs/activation.jar, and /app/libs/additionnal.jar - you can go ahead and remove them; both google() and maven() repositories are enabled in Android projects, and the latest deps are available there. They include new META-INF files, so we'll also need to remove them from the build when we update the deps;
to your project-level gradle file (/build.gradle):
buildscript {
ext {
// ...
java_mail_version = "1.6.7"
}
// ...
}
// ...
to your app/module-level gradle file (/app/build.gradle):
//...
android {
// ...
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
excludes += '/META-INF/{NOTICE.md,LICENSE.md}' // <-- This line
}
}
}
// ...
dependencies {
// ...
// Dumb Email Sending
implementation "com.sun.mail:android-mail:$java_mail_version"
// REMOVE THESE - DEPS WILL DOWNLOAD AUTOMATICALLY
//implementation 'com.sun.mail:android-activation:1.6.7' // from 1.6.4
//implementation 'com.sun.mail:android-additionnal:1.6.7' // from 1.6.4
}
// ...
That's it, issue resolved on API Level 30 - and no more lugging the .jar files around (if you were).
I have the following code in a map activity :
PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment)
getFragmentManager().findFragmentById(R.id.autocomplete_fragment);
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
#Override
public void onPlaceSelected(Place place) {
// TODO: Get info about the selected place.
destination = place.getName().toString();
}
#Override
public void onError(Status status) {
// TODO: Handle the error.
}
});
}
This is the XML fragment:
<fragment android:id="#+id/autocomplete_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"/>
Here is my app build.gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.site.test"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
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.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.github.bumptech.glide:glide:4.0.0'
//implementation 'com.google.android.gms:play-services:12.0.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.firebase:geofire-android:2.1.1'
implementation 'com.android.support:cardview-v7:21.0.+'
implementation 'com.google.android.gms:play-services-places:16.0.0'
//below added for testing
//implementation 'com.google.android.libraries.places:1.0.0'
`enter code here`}
apply plugin: 'com.google.gms.google-services'
Once the map activity is activated, I see the fragment search box in it's correct placement. Once I click it, the search box pop-up briefly appears then disappears, effectively stopping me from entering a location.
I have enabled the Google Places API, and it is correctly placed in my android manifest file.
This is what the logcat shows :
2019-03-04 00:58:55.090 6506-6506/com.site.test E/SchedPolicy: set_timerslack_ns write failed: Operation not permitted
Seems to be an issue in Places, try this
https://stackoverflow.com/a/55073542/11551260
I made a Bluetooth app. It works fine in Nougat, Marshmallow, Jelly Bean, KitKat but for reason, it crashes in Android Lollipop when Discover button (which discovers all the discoverable devices) is clicked.
Here is the method which gets triggered on clicking Discover button -
private void discoverDevices() {
Log.d(TAG, "btnDiscover: Looking for unpaired devices.");
if(mBluetoothAdapter.isDiscovering()){
mBluetoothAdapter.cancelDiscovery();
Log.d(TAG, "btnDiscover: Canceling discovery.");
//check BT permissions in manifest
checkBTPermissions();
mBluetoothAdapter.startDiscovery();
IntentFilter discoverDevicesIntent = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mBroadcastReceiver3, discoverDevicesIntent);
}
if(!mBluetoothAdapter.isDiscovering()){
//check BT permissions in manifest
checkBTPermissions();
mBluetoothAdapter.startDiscovery();
IntentFilter discoverDevicesIntent = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mBroadcastReceiver3, discoverDevicesIntent);
}
}
CheckBTPermissions()-
private void checkBTPermissions() {
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP){
int permissionCheck = this.checkSelfPermission("Manifest.permission.ACCESS_FINE_LOCATION");
permissionCheck += this.checkSelfPermission("Manifest.permission.ACCESS_COARSE_LOCATION");
if (permissionCheck != 0) {
this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1001); //Any number
}
}else{
Log.d(TAG, "checkBTPermissions: No need to check permissions. SDK version
=< LOLLIPOP.");
}
}
Permissions in Manifest file-
<uses-feature android:name="android.hardware.bluetooth" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
build.gradle-
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.example.hpi5.bluetooth"
minSdkVersion 16
targetSdkVersion 25
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'])
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.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
I have not tested this app on Lollipop myself as I don't have any device running on Android L. I got to know about the crash from a friend of mine.
EDIT: I managed to arrange the logs.
07-07 19:29:00.219 30852-30852/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.hpi5.bluetooth, PID: 30852
java.lang.NoSuchMethodError: No virtual method checkSelfPermission(Ljava/lang/String;)I in class Lcom/example/hpi5/bluetooth/MainActivity; or its super classes (declaration of 'com.example.hpi5.bluetooth.MainActivity' appears in /data/app/com.example.hpi5.bluetooth-1/base.apk)
at com.example.hpi5.bluetooth.MainActivity.checkBTPermissions(MainActivity.java:243)
at com.example.hpi5.bluetooth.MainActivity.discoverDevices(MainActivity.java:230)
at com.example.hpi5.bluetooth.MainActivity.access$100(MainActivity.java:24)
at com.example.hpi5.bluetooth.MainActivity$7.onClick(MainActivity.java:189)
at android.view.View.performClick(View.java:4923)
at android.view.View$PerformClick.run(View.java:20341)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5717)
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:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
The exception says it all, the method checkSelfPermission is only available on API 23 onwards. If you want to check permission with API 21, use the Android support library and ContextCompat.checkSelfPermission
Edit: Also, location permissions for Bluetooth are only required from API 23 onwards.
So I arranged the logs somehow and found even for devices running on Lollipop the following condition was evaluating to true
if(Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP){
//code here
}
and because of this, the app was crashing on clicking the Discover button.
So, I just changed the above condition to -
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
}
The app is working fine on Lollipop devices now.
Why was it crashing on Lollipop devices earlier?
So, my friend's device was running on Android version 5.1.1 and that is why the condition was evaluating to true. And since checkSelfPermission was introduced in API level 23 (Android M), the app could not find it and thus crashed.
Runtime permission system was added in API 23, so you shouldn't check permissions under that API. And logcat tells you that it can't find a method that didn't existed in API 21.
I have been working on a project for months without issues. Just today re-opened the project in Android Studio and started getting the error:
Gradle sync failed: Failed to notify project evaluation listener.
I already tried this and this, without success.
I also cleaned cache, rebuilt project, restarted my pc, uninstalled and reinstalled Android Support and Google libraries in SDK, and tried with Invalidate Cache and restart. None of these things worked.
And I'm using Android Studio 2.1.1, just in case.
I hope someone could help me fix this issue. Thanks in advance.
LOG:
Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:55)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:79)
at org.gradle.internal.event.BroadcastDispatch.dispatch(BroadcastDispatch.java:30)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy10.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:67)
... 94 more
Caused by: java.lang.StackOverflowError
at com.google.common.base.Objects.hashCode(Objects.java:78)
at com.android.build.gradle.internal.dependency.LibraryDependencyImpl.hashCode(LibraryDependencyImpl.java:145)
at com.google.common.collect.AbstractMapBasedMultimap.put(AbstractMapBasedMultimap.java:192)
at com.google.common.collect.AbstractListMultimap.put(AbstractListMultimap.java:100)
at com.google.common.collect.ArrayListMultimap.put(ArrayListMultimap.java:66)
at com.android.build.gradle.internal.DependencyManager.addDependency(DependencyManager.java:807)
at com.android.build.gradle.internal.DependencyManager.addDependency(DependencyManager.java:855)
at com.android.build.gradle.internal.DependencyManager.addDependency(DependencyManager.java:855)
at com.android.build.gradle.internal.DependencyManager.addDependency(DependencyManager.java:855)
2016-05-29 15:34:00,668 [ 193987] WARN - nal.AbstractExternalSystemTask - Failed to notify project evaluation listener.
com.intellij.openapi.externalSystem.model.ExternalSystemException: Failed to notify project evaluation listener.
at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:457)
at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:158)
at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:350)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:373)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:339)
at org.jetbrains.plugins.gradle.service.project.GradleExecutionHelper.execute(GradleExecutionHelper.java:230)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:97)
at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:65)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:419)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:500)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:366)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:55)
2016-05-29 15:34:00,683 [ 194002] WARN - radle.project.ProjectSetUpTask -
2016-05-29 15:34:00,683 [ 194002] INFO - radle.project.ProjectSetUpTask - Failed to notify project evaluation listener.
Consult IDE log for more details (Help | Show Log)
2016-05-29 15:34:00,683 [ 194002] INFO - ls.idea.gradle.GradleSyncState - Sync with Gradle for project 'IconShowcase' failed: Failed to notify project evaluation listener.
Consult IDE log for more details (Help | Show Log)
2016-05-29 15:34:00,902 [ 194221] INFO - #com.jetbrains.cidr.lang - Clearing symbols finished in 0 s.
2016-05-29 15:34:00,969 [ 194288] INFO - #com.jetbrains.cidr.lang - Loading symbols finished in 0 s.
2016-05-29 15:34:01,016 [ 194335] INFO - #com.jetbrains.cidr.lang - Building symbols finished in 0 s.
2016-05-29 15:34:01,016 [ 194335] INFO - #com.jetbrains.cidr.lang - Saving symbols finished in 0 s.
PROJECT STRUCTURE
app build.gradle
apply plugin: 'com.android.application'
repositories {
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
lintOptions {
abortOnError false
}
defaultConfig {
applicationId "jahirfiquitiva.apps.iconshowcase.sample"
minSdkVersion 16
targetSdkVersion 23
versionCode 10
versionName "1.0"
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
sourceSets {
main {
res.srcDirs = [
'src/main/res',
'src/main/res/drawable',
'src/main/res/drawable/dashboard',
'src/main/res/drawable/designer',
'src/main/res/drawable/icon_pack',
'src/main/res/drawable/launchers_icons',
'src/main/res/drawable/widgets',
'src/main/res/values',
'src/main/res/values/icon_pack',
'src/main/res/values/configuration'
]
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
themeMode {} //themeMode for testing
standard {} //standard testing without themeMode stuff
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile project(':library')
}
library build.gradle
buildscript {
repositories {
mavenCentral()
}
}
apply plugin: 'com.android.library'
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 10
versionName "1.0"
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
sourceSets {
main {
res.srcDirs = [
'src/main/res',
'src/main/res/drawable',
'src/main/res/drawable/dashboard',
'src/main/res/drawable/designer',
'src/main/res/drawable/icon_pack',
'src/main/res/drawable/launchers_icons',
'src/main/res/drawable/splash_screens',
'src/main/res/drawable/widgets',
'src/main/res/layout',
'src/main/res/layout/activities',
'src/main/res/layout/extras',
'src/main/res/layout/items',
'src/main/res/layout/sections',
'src/main/res/layout/widgets',
'src/main/res/values/icon_pack',
'src/main/res/values/configuration',
'src/main/res/values/texts'
]
}
}
buildTypes {
release {
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
aaptOptions {
noCompress 'zip', 'komp', 'klwp', 'kwgt', 'klck', 'kwch'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0#aar'
compile 'com.android.support:support-v4:23.4.0#aar'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0#aar'
compile 'com.android.support:recyclerview-v7:23.4.0#aar'
compile 'com.android.support:palette-v7:23.4.0#aar'
compile 'com.android.support:gridlayout-v7:23.4.0'
compile 'com.android.support:customtabs:23.4.0'
//Material Dialogs
compile('com.github.afollestad.material-dialogs:core:0.8.5.9#aar') {
transitive = true
}
//Material Drawer
compile('com.mikepenz:materialdrawer:5.2.7#aar') {
transitive = true
}
//OkHttp
compile 'com.squareup.okhttp3:okhttp:3.3.1'
//Glide Library - Image Loading Lib
compile 'com.github.bumptech.glide:glide:3.8.0-SNAPSHOT'
//Sectioned RecyclerView
compile('com.afollestad:sectioned-recyclerview:0.2.2') {
transitive = true
}
compile 'com.truizlop.sectionedrecyclerview:library:1.1.0'
//Muzei API
//noinspection GradleDynamicVersion
compile 'com.google.android.apps.muzei:muzei-api:2.+'
//Circular Image View
compile 'de.hdodenhof:circleimageview:2.0.0'
//RecyclerView Fast Scroller
compile 'com.github.pluscubed:recycler-fast-scroll:0.3.1#aar'
//Donations Lib
compile 'org.sufficientlysecure:donations:2.4'
//License Checker Lib
compile 'com.github.javiersantos:PiracyChecker:0.0.2'
//Required for better Zooper setup
compile 'io.reactivex:rxandroid:1.1.0'
//Required for Kustom support.
//noinspection GradleDynamicVersion
compile 'org.bitbucket.frankmonza:kustomapi:+'
}
settings.gradle
include ':app', ':library'
I had a similar problem when I moved to a higher level of gradle. Found the answer here. Try changing the gradle level
In my case, this version helped
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
and this gradele version throws mistakes
'com.android.tools.build:gradle:2.2.2'
'com.android.tools.build:gradle:3.0.0'
Just do not forget to change distributionUrl in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
Fixed it by changing the MaterialDialogs lib version to
compile('com.afollestad.material-dialogs:core:0.8.5.9#aar') { transitive = true }
I downloaded an old repository from GitHub and tried to update some versions. Then got this error. After I reverted back
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-all.zip
as #Kamila suggested, the error disappeared.