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.
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",
Apologies if this question seems obvious. I have built an JAVAFX project in intellij on OSX. When I open this project up on a windows machine still in intellij, the compiler cant find any of the imported classes .
If I delete the imports and then alt-enter, intellij finds them straight away, yet still wont find them when compiling.
Is this due to the project being built with the OSX SDK and libraries?
Java FX\JavaFX-Events-
Continued-Source-code\src\sample\Main.java
Error:(3, 26) java: package javafx.application does not exist
Error:(4, 19) java: package javafx.fxml does not exist
Error:(5, 20) java: package javafx.scene does not exist
Error:(6, 20) java: package javafx.scene does not exist
Error:(7, 20) java: package javafx.stage does not exist
Error:(9, 27) java: cannot find symbol
symbol: class Application
Error:(12, 23) java: cannot find symbol
symbol: class Stage
location: class sample.Main
Error:(11, 5) java: method does not override or implement a method from a supertype
Error:(13, 9) java: cannot find symbol
symbol: class Parent
location: class sample.Main
Error:(13, 39) java: cannot find symbol
symbol: method getClass()
location: class sample.Main
Error:(13, 23) java: cannot find symbol
symbol: variable FXMLLoader
location: class sample.Main
Error:(15, 35) java: cannot find symbol
symbol: class Scene
location: class sample.Main
Error:(21, 9) java: cannot find symbol
symbol: method launch(java.lang.String[])
location: class sample.Main
I'm trying to compile some edited source code from here, however I keep getting many errors regarding a package named "javax.persistence".
This is my IDE version -
IntelliJ IDEA 2016.2.4
Build #IC-162.2032.8, built on September 9, 2016
JRE: 1.8.0_112-release-b343 x86
JVM: OpenJDK Server VM by JetBrains s.r.o
My JDK seems to not include this package, as I have linked the whole JDK in the SDK tab. Does anyone know what i'm doing wrong? This is the output of my messages window -
Information:Using javac 1.8.0_101 to compile java sources
Information:java: Errors occurred while compiling module 'BctalkBumpBot-1.0'
Information:2/10/2016 9:10 PM - Compilation completed with 37 errors and 3 warnings in 3s 3ms
Warning:java: source value 1.5 is obsolete and will be removed in a future release
Warning:java: target value 1.5 is obsolete and will be removed in a future release
Warning:java: To suppress warnings about obsolete options, use -Xlint:-options.
C:\Users\gabri\Desktop\BctalkBumpBot-1.0\src\com\achow101\bumpbot\BumpEntry.java
Error:(21, 1) java: package javax.persistence does not exist
Error:(26, 2) java: cannot find symbol
symbol: class Entity
Error:(29, 6) java: cannot find symbol
symbol: class Id
location: class com.achow101.bumpbot.BumpEntry
C:\Users\gabri\Desktop\BctalkBumpBot-1.0\src\com\achow101\bumpbot\DoBumps.java
Error:(26, 25) java: package javax.persistence does not exist
Error:(27, 25) java: package javax.persistence does not exist
Error:(28, 25) java: package javax.persistence does not exist
Error:(29, 25) java: package javax.persistence does not exist
Error:(30, 34) java: package javax.persistence.criteria does not exist
Error:(31, 34) java: package javax.persistence.criteria does not exist
Error:(32, 34) java: package javax.persistence.criteria does not exist
Error:(48, 9) java: cannot find symbol
symbol: class EntityManagerFactory
location: class com.achow101.bumpbot.DoBumps
Error:(48, 36) java: cannot find symbol
symbol: variable Persistence
location: class com.achow101.bumpbot.DoBumps
Error:(49, 9) java: cannot find symbol
symbol: class EntityManager
location: class com.achow101.bumpbot.DoBumps
Error:(50, 9) java: cannot find symbol
symbol: class CriteriaBuilder
location: class com.achow101.bumpbot.DoBumps
Error:(56, 17) java: cannot find symbol
symbol: class CriteriaQuery
location: class com.achow101.bumpbot.DoBumps
Error:(57, 17) java: cannot find symbol
symbol: class Root
location: class com.achow101.bumpbot.DoBumps
Error:(59, 17) java: cannot find symbol
symbol: class TypedQuery
location: class com.achow101.bumpbot.DoBumps
C:\Users\gabri\Desktop\BctalkBumpBot-1.0\src\com\achow101\bumpbot\BumpBot.java
Error:(40, 25) java: package javax.persistence does not exist
Error:(41, 25) java: package javax.persistence does not exist
Error:(42, 25) java: package javax.persistence does not exist
Error:(43, 25) java: package javax.persistence does not exist
Error:(44, 34) java: package javax.persistence.criteria does not exist
Error:(45, 34) java: package javax.persistence.criteria does not exist
Error:(46, 34) java: package javax.persistence.criteria does not exist
Error:(113, 9) java: cannot find symbol
symbol: class EntityManagerFactory
location: class com.achow101.bumpbot.BumpBot
Error:(113, 36) java: cannot find symbol
symbol: variable Persistence
location: class com.achow101.bumpbot.BumpBot
Error:(114, 9) java: cannot find symbol
symbol: class EntityManager
location: class com.achow101.bumpbot.BumpBot
Error:(117, 9) java: cannot find symbol
symbol: class CriteriaBuilder
location: class com.achow101.bumpbot.BumpBot
Error:(118, 9) java: cannot find symbol
symbol: class CriteriaQuery
location: class com.achow101.bumpbot.BumpBot
Error:(119, 9) java: cannot find symbol
symbol: class Root
location: class com.achow101.bumpbot.BumpBot
Error:(121, 9) java: cannot find symbol
symbol: class TypedQuery
location: class com.achow101.bumpbot.BumpBot
Error:(165, 17) java: cannot find symbol
symbol: class EntityManagerFactory
Error:(165, 44) java: cannot find symbol
symbol: variable Persistence
Error:(166, 17) java: cannot find symbol
symbol: class EntityManager
Error:(287, 17) java: cannot find symbol
symbol: class EntityManagerFactory
Error:(287, 44) java: cannot find symbol
symbol: variable Persistence
Error:(288, 17) java: cannot find symbol
symbol: class EntityManager
Any help is appreciated.
Learn to read error messages. You're trying to compile something that requires javax.persistence classes. These are not included in the standard libraries (they were at some point but haven't been for years).
Also, you indeed don't have an actual JDK installed, but a JRE. IntelliJ apparently doesn't mind all that much, which kinda surprises me. Seems it is using an internal compiler.
Install a JDK, get a JEE or at least a JPA implementation from somewhere (Hibernate or Eclipselink are good), and away you go.
Apparently, sometimes the main Java package doesn't contain javax.persistence depending on the version of Java that you're using. In that case you will get an error java: package javax.persistence does not exist.
All you have to do in that case is add another dependency for javax.persistence
<!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
Source: https://ranvir.xyz/blog/building-restful-apis-with-java-spring-boot-framework-for-beginners/
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.