Error when I Migrate my project to androidx? - java

My project
Main class
I successfully migrated my project to androidx .
after I build my project it occurs an error in build folder.
error at build folder
Error :
`D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\MainActivity_ViewBinding.java:4: error: package android.support.annotation does not exist
import android.support.annotation.CallSuper;
^
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\MainActivity_ViewBinding.java:5: error: package android.support.annotation does not exist
import android.support.annotation.UiThread;
^
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\PopupMenuDialog_ViewBinding.java:4: error: package android.support.annotation does not exist
import android.support.annotation.CallSuper;
^
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\PopupMenuDialog_ViewBinding.java:5: error: package android.support.annotation does not exist
import android.support.annotation.UiThread;
^
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\MainActivity_ViewBinding.j
ava:22: error: cannot find symbol
#UiThread
^
symbol: class UiThread
location: class MainActivity_ViewBinding
where T is a type-variable:
T extends MainActivity declared in class MainActivity_ViewBinding
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\MainActivity_ViewBinding.j
`
ava:42: error: cannot find symbol
#CallSuper
^
symbol: class CallSuper
location: class MainActivity_ViewBinding
where T is a type-variable:
T extends MainActivity declared in class MainActivity_ViewBinding
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\PopupMenuDialog_ViewBin
ding.java:25: error: cannot find symbol
#UiThread
^
symbol: class UiThread
location: class PopupMenuDialog_ViewBinding
where T is a type-variable:
T extends PopupMenuDialog declared in class PopupMenuDialog_ViewBinding
D:\jp\ft\FileTransfer\app\build\generated\ap_generated_sources\debug\out\me\pengtao\filetransfer\PopupMen
uDialog_ViewBinding.java:64: error: cannot find symbol
#CallSuper
^
symbol: class CallSuper
location: class PopupMenuDialog_ViewBinding<T>
where T is a type-variable:
T extends PopupMenuDialog declared in class PopupMenuDialog_ViewBinding
8 errors
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log
output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 33s
17 actionable tasks: 9 executed, 8 up-to-date
How can I solve this ?

AndroidX and Butterknife only works with 9.0.0-SNAPSHOT or later
you can update your define in build.gradle as below
butterknife : "com.jakewharton:butterknife:10.2.1",
butterknifeCompiler: "com.jakewharton:butterknife-compiler:10.2.1",

Related

compilation failed "Task :app:compileDebugJavaWithJavac FAILED"

this error randomly popped up after i tried running my ionic cordova app. this not only happens on my branch ive been working on but also with every other branch i try to run, which leads me to believe it is something with my machine. ive tried restarting and reinstalling the packages and it hasnt solved the issue.
> ionic-app-scripts.cmd build --target cordova --platform android
[23:25:18] ionic-app-scripts 3.2.4
[23:25:18] build dev started ...
[23:25:18] clean started ...
[23:25:18] clean finished in 21 ms
[23:25:18] copy started ...
[23:25:18] deeplinks started ...
[23:25:18] deeplinks finished in 515 ms
[23:25:18] transpile started ...
[23:25:25] transpile finished in 6.59 s
[23:25:25] preprocess started ...
[23:25:25] preprocess finished in less than 1 ms
[23:25:25] webpack started ...
[23:25:25] copy finished in 7.26 s
[23:25:30] webpack finished in 5.09 s
[23:25:30] sass started ...
[23:25:32] sass finished in 1.82 s
[23:25:32] postprocess started ...
[23:25:32] postprocess finished in 14 ms
[23:25:32] lint started ...
[23:25:32] build dev finished in 14.19 s
no-unused-variable is deprecated. Since TypeScript 2.9. Please use the built-in compiler checks instead.
[23:25:36] lint finished in 4.22 s
> cordova.cmd build android
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=undefined (DEPRECATED)
Using Android SDK: C:\Users\IvanTzenev\AppData\Local\Android\sdk
Subproject Path: CordovaLib
Subproject Path: app
> Task :app:compileDebugJavaWithJavac FAILED
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\com\ionicframework\cordova\webview\IonicWebViewEngine.java:11: error: package android.support.annotation does not exist
import android.support.annotation.RequiresApi;
^
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic.java:57: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic_External_Storage.java:28: error: cannot find symbol
import android.support.v4.os.EnvironmentCompat;
^
symbol: class EnvironmentCompat
location: package android.support.v4.os
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic_Notifications.java:35: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
^
symbol: class NotificationManagerCompat
location: package android.support.v4.app
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\org\apache\cordova\camera\CameraLauncher.java:40: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\org\apache\cordova\camera\CordovaUri.java:25: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\org\apache\cordova\camera\FileProvider.java:21: error: package android.support.v4.content does not exist
public class FileProvider extends android.support.v4.content.FileProvider {}
^
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\com\ionicframework\cordova\webview\IonicWebViewEngine.java:137: error: cannot find symbol
#RequiresApi(Build.VERSION_CODES.LOLLIPOP)
^
symbol: class RequiresApi
location: class IonicWebViewEngine.ServerClient
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic.java:648: error: cannot find symbol
java.lang.reflect.Method method = ActivityCompat.class.getMethod("shouldShowRequestPermissionRationale", Activity.class, java.lang.String.class);
^
symbol: class ActivityCompat
location: class Diagnostic
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic_External_Storage.java:216: error: cannot find symbol
addPath = Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(file));
^
symbol: variable EnvironmentCompat
location: class Diagnostic_External_Storage
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic_Notifications.java:123: error: cannot find symbol
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this.cordova.getActivity().getApplicationContext());
^
symbol: class NotificationManagerCompat
location: class Diagnostic_Notifications
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\cordova\plugins\Diagnostic_Notifications.java:123: error: cannot find symbol
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this.cordova.getActivity().getApplicationContext());
^
symbol: variable NotificationManagerCompat
location: class Diagnostic_Notifications
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\org\apache\cordova\camera\CameraLauncher.java:303: error: cannot find symbol
this.imageUri = new CordovaUri(FileProvider.getUriForFile(cordova.getActivity(),
^
symbol: method getUriForFile(Activity,String,File)
location: class FileProvider
C:\GitHub\Accentis-Ionic\platforms\android\app\src\main\java\org\apache\cordova\camera\CameraLauncher.java:801: error: cannot find symbol
Uri tmpFile = FileProvider.getUriForFile(cordova.getActivity(),
^
symbol: method getUriForFile(Activity,String,File)
location: class FileProvider
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
14 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.5/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
21 actionable tasks: 1 executed, 20 up-to-date
Command failed with exit code 1: C:\GitHub\Accentis-Ionic\platforms\android\gradlew cdvBuildDebug -b C:\GitHub\Accentis-Ionic\platforms\android\build.gradle
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
i think you are missing these v4 libraries or dependencies are not getting sync properly. first thing you can invalidate/restart(file menu in Android studio) your project and if still not working then can check below link: package android.support.v4.app does not exist ; in Android studio 0.8

Flutter/Dart - FlutterFirebaseMessagingPlugin.java - Build fails with Exception "error: cannot find symbol"

After upgrading to Null Safety sdk: ">=2.12.0 <3.0.0" I'm getting errors when I try to build my Flutter app in Android Studio.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:20: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceId;
^
symbol: class FirebaseInstanceId
location: package com.google.firebase.iid
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:21: error: cannot find symbol
import com.google.firebase.iid.Metadata;
^
symbol: class Metadata
location: package com.google.firebase.iid
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:152: error: cannot find symbol
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
^
symbol: variable Metadata
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:153: error: cannot find symbol
FirebaseInstanceId.getInstance().deleteToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:165: error: cannot find symbol
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
^
symbol: variable Metadata
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:166: error: cannot find symbol
String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
Android Studio tells me FlutterFirebaseMessagingPlugin.java "cannot find symbol". So what does this mean and how do I fix it
Update your firebase_messaging in pusbpec.yaml to version that supports null-safety (for example: firebase_messaging: ^10.0.0, and call flutter pub get from terminal
First, get the latest versions of your firebase dependencies from pub.dev
Run the commands:
flutter pub upgrade
flutter pub get
flutter clean
Invalidate caches and restart
and then try running the app
For me, the problem was that I updated androidx core version from 1.0.1 to 1.5.0 in my app/gradle file but I didn't update it in project level gradle file in resolutionStrategy
They both should be the same.

Javac compilation error

I am trying to compile a Java class but I get this error:
TestRunner.java
TestRunner.java:3: error: package org.junit.runner does not exist
import org.junit.runner.JUnitCore;
^
TestRunner.java:4: error: package org.junit.runner does not exist
import org.junit.runner.Result;
^
TestRunner.java:5: error: package org.junit.runner.notification does not exist
import org.junit.runner.notification.Failure;
^
TestRunner.java:9: error: cannot find symbol
Result result = JUnitCore.runClasses(ApplicationIT.class);
^
symbol: class Result
location: class TestRunner
TestRunner.java:9: error: cannot find symbol
Result result = JUnitCore.runClasses(ApplicationIT.class);
It is unable to resolve any of the import packages and classes.
I'm not sure what is wrong?
Thanks
Got the same error, but
Closing android studio,cleaning the build and again rebuilding it solved my error.

error: package org.picketlink.idm.internal does not exist

I changed my pom.xml to add picktlink-social so I changed my pom to remove picketlink-deltaspike, and addeda apache deltaspike because I had some redundancy issues with picktlink detlaspike, and for a while my app worked.
So every once in a while when I did a mvn clean, I got this error
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile (default-compile) on project unikaimagen: Compilation failure: Compilation failure:
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[33,34] error: package org.picketlink.idm.internal does not exist
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[35,30] error: package org.picketlink.internal does not exist
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[70,9] error: cannot find symbol
[ERROR] symbol: class EEJPAContextInitializer
[ERROR] location: class IDMConfiguration
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[33,34] error: package org.picketlink.idm.internal does not exist
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[35,30] error: package org.picketlink.internal does not exist
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[70,9] error: cannot find symbol
[ERROR] symbol: class EEJPAContextInitializer
[ERROR] location: class IDMConfiguration
[ERROR] /home/jdc/git/unikaimagen/src/main/java/ec/com/unikaimagen/init/IDMConfiguration.java:[110,25] error: cannot find symbol
[ERROR] -> [Help 1]
So I changed the version of picketlink from 2.6.1 to 2.6.0 or 2.6.0 to 2.6.1 and it compiled again. But now that is not even working,
This is my pom.xml http://pastebin.com/9bRMrGkv.
org.picketlink.internal should be in picketlink-impl module, which is included in my pom.xml
This is my IDMConfiguration.java http://pastebin.com/XES0WyDQ
http://pastebin.com/XES0WyDQ
I did a jarscan and found this
$ java -jar jarscan.jar -d /home/jdc/.m2/repository/ EEJPAContextInitializer
.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
+/home/jdc/.m2/repository/org/picketlink/picketlink-impl/2.6.0.Final/picketlink-impl-2.6.0.Final.jar
/home/jdc/.m2/repository/org/picketlink/picketlink-impl/2.6.0.Final/picketlink-impl-2.6.0.Final.jar/org/picketlink/internal/EEJPAContextInitializer.class
+/home/jdc/.m2/repository/org/picketlink/picketlink-impl/2.6.0.CR2/picketlink-impl-2.6.0.CR2.jar
/home/jdc/.m2/repository/org/picketlink/picketlink-impl/2.6.0.CR2/picketlink-impl-2.6.0.CR2.jar/org/picketlink/internal/EEJPAContextInitializer.class
+/home/jdc/.m2/repository/org/picketlink/picketlink-impl/2.6.1.Final/picketlink-impl-2.6.1.Final.jar
/home/jdc/.m2/repository/org/picketlink/picketlink-impl/2.6.1.Final/picketlink-impl-2.6.1.Final.jar/org/picketlink/internal/EEJPAContextInitializer.class
----------------------------------------------
I had the same problem when I updated the picketlink version. I checked your pom and I realized that it contains
<dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-api</artifactId>
</dependency>
which specifies all the dependencies, but you have also added each module separately. So, I think you should delete them and try again.

Jenkins Build Failed error: cannot find symbol

I have done my Automation in java using Junit and push that code to bitbucket and integrated it with jenkins. But when i am starting build after creating job it start failling and throwing some error. i am not able get that why it is not taking class path and how i can set class path to avoid this issue
Here is error coming on console
[javac] C:\Program Files\Jenkins\workspace\ABC-first-job\tst\com\cb\abc\ABCTest.java:110: error: cannot find symbol
[javac] Assert.assertTrue(response.contains(ABCConstant.DATA_MESSAGE));
[javac] ^
[javac] symbol: variable Assert
[javac] location: class ABCTest
[javac] 47 errors
BUILD FAILED
C:\Program Files\Jenkins\workspace\ABC-first-job\build.xml:48: Compile failed; see the compiler error output for details.
Total time: 2 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Check if there was any recent jdk version updates for jdk used to build the code. If you have a slave node also check the jdk version on the same.

Categories