Cannot find symbol import android support v4 app activitycompat

Any idea about this error? cannot find symbol import android.support.v4.app.ActivityCompat; #22

Comments

wyxcoder commented Feb 22, 2019

C:\Tools\flutter.pub-cache\hosted\pub.dartlang.org\permission-0.1.1\android\src\main\java\com\ly\permission\PermissionPlugin.java:10: error: cannot find symbol
import android.support.v4.app.ActivityCompat;
^
symbol: class ActivityCompat
location: package android.support.v4.app
C:\Tools\flutter.pub-cache\hosted\pub.dartlang.org\permission-0.1.1\android\src\main\java\com\ly\permission\PermissionPlugin.java:11: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;

The text was updated successfully, but these errors were encountered:

xuwankang commented Mar 13, 2019

devadrianapostol commented Mar 14, 2019

It’s an AndroidX issue. I tried to fix it. Created pull request.
You can use my fork.
https://github.com/devadrianapostol/permission

marianoarga commented Apr 11, 2019

ezraaaa commented Apr 22, 2019

@devadrianapostol how can i use your fork?

marianoarga commented Apr 22, 2019

@ezraaaa Add in your pubspec.yaml:

mikes222 commented May 6, 2019

The fix is working. Please accept the pull request.

once10301 commented Jun 5, 2019

I have fixed it, can you try it again?

Nastya-Scherbakova commented Jun 6, 2019

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

Android Android support v4 content missing

Menestroll

Member

Hi ! I try to compile a GMS2 project with the java extension CamSurface.
But i have an error compilation caused by a package missing.

I contact the author who told me to add Support Library under Extra Folder in the Android SDK Manager.
But there is no Support Library in the new SDK Manager in Android Studio.

I guess this is a problem with graddle version or android library.

How can i fix this issue ?

My SDK settings are API Level 28 Build Tool : 28.0.3 Helper Library: 28.0.0 Targer Sdk : 28 Min Sdk : 16 Compile SDK : 28.
GMS 2 version 2.2.5
Android v 3.5

Читайте также:  Boating navionics для андроид

chirpy

Member

I haven’t tried, but theoretically you can add the package to the extension’s gradle dependencies injection field, and let gradle handle the rest of installation etc.
https://developer.android.com/topic/libraries/support-library/setup
https://developer.android.com/topic/libraries/support-library

Double click your extension in the IDE, under «Extra Platforms» -> select «Android» -> Extension Android Properties window -> Inject to gradle dependencies

That said, GMS2 migrated the official Google Play Services extensions to androidx since 2.2.4 following Google’s push,
and so we’re recommended to use androidx instead of the deprecated support library.

Gradle dependency and class mappings can be found at:
https://developer.android.com/jetpack/androidx/migrate#mappings
However, the java extension also needs to migrate.

Attachments

Menestroll

Member

Hi,
Thank’s for your reply.
I followed your instructions but it doesn’t work.
I also tried to add in RootFiles/build.gradle some repo as Maven and differents gradle build in the dependencies.

My debug output (expanded version)

chirpy

Member

@Menestroll
For not migrating, you’d only need to try adding
«implementation «com.android.support:support-v4:28.0.0» into your extension’s «Extra Platforms» -> «Inject to gradle dependencies»

Nothing to do with RootFiles/build.gradle; you don’t need to touch those.
It’s not that a repository is missing there in the gradle settings, but your extension did not say it needs the missing package: you need to declare the dependency in «Extra Platforms» -> «Inject to gradle dependencies».
(As in previously attached screenshot).

It seems that you already tried it and failed, but I don’t see related logs.
We can try and see if there are conflicts, if it failed, you can contact the extension’s author to do the migration for you.
It may or may not be too difficult to resolve; sometimes it’s as simple as changing the classes as the mapping site says but I don’t know. I can only wish you good luck.

[Edit: sorry, it seems that I don’t know what the errors are really saying]

FrostyCat

Member

Menestroll

Member

Hi, thanks for your help !

I downgraded Android Studio to version 3.5, and GMS 2 to build 2.2.3.436. I also removed android sdk before download it again.

And the build didn’t fail ! . the first time xD

Источник

Cannot find symbol import android.support.v4.app.NotificationManagerCompat #1082

Comments

mishkeTz commented Jun 18, 2019

Hi,
Few days ago I had a problem described in #1058 when building an app, and I fixed it when I followed the steps they suggested. But today when I tried to build for the release I got another error and I can’t find the solution for it.

Task :app:compileReleaseJavaWithJavac FAILED
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:9: error: cannot find symbol
import android.support.v4.app.NotificationManagerCompat;
^
symbol: class NotificationManagerCompat
location: package android.support.v4.app
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:11: error: cannot find symbol
import android.support.v4.app.NotificationCompat;
^
symbol: class NotificationCompat
location: package android.support.v4.app
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:358: error: cannot find symbol
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
^
symbol: class NotificationManagerCompat
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:358: error: cannot find symbol
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
^
symbol: variable NotificationManagerCompat
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:144: error: package NotificationCompat does not exist
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
^
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:144: error: package NotificationCompat does not exist
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
^
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:153: error: cannot find symbol
.setPriority(NotificationCompat.PRIORITY_MAX);
^
symbol: variable NotificationCompat
location: class FirebasePluginMessagingService
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:149: error: package NotificationCompat does not exist
.setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
^
D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:148: error: cannot find symbol
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
^
symbol: variable NotificationCompat
location: class FirebasePluginMessagingService
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.
9 errors
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:compileReleaseJavaWithJavac’.

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 13s
    33 actionable tasks: 5 executed, 28 up-to-date
    (node:6280) UnhandledPromiseRejectionWarning: Error: D:\Cordova\MyApp\platforms\android\gradlew: Command failed with exit code 1 Error output:
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:9: error: cannot find symbol
    import android.support.v4.app.NotificationManagerCompat;
    ^
    symbol: class NotificationManagerCompat
    location: package android.support.v4.app
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:11: error: cannot find symbol
    import android.support.v4.app.NotificationCompat;
    ^
    symbol: class NotificationCompat
    location: package android.support.v4.app
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:358: error: cannot find symbol
    NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
    ^
    symbol: class NotificationManagerCompat
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:358: error: cannot find symbol
    NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(context);
    ^
    symbol: variable NotificationManagerCompat
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:144: error: package NotificationCompat does not exist
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
    ^
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:144: error: package NotificationCompat does not exist
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
    ^
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:153: error: cannot find symbol
    .setPriority(NotificationCompat.PRIORITY_MAX);
    ^
    symbol: variable NotificationCompat
    location: class FirebasePluginMessagingService
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:149: error: package NotificationCompat does not exist
    .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody))
    ^
    D:\Cordova\MyApp\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:148: error: cannot find symbol
    .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
    ^
    symbol: variable NotificationCompat
    location: class FirebasePluginMessagingService
    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.
    9 errors
    FAILURE: Build failed with an exception.
  • What went wrong:
    Execution failed for task ‘:app:compileReleaseJavaWithJavac’.

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
Читайте также:  Что значит операционная система android

BUILD FAILED in 13s
at ChildProcess.whenDone (D:\Cordova\MyApp\node_modules\cordova-common\src\superspawn.js:135:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at ChildProcess.cp.emit (D:\Cordova\MyApp\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (internal/child_process.js:915:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:6280) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6280) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The text was updated successfully, but these errors were encountered:

Источник

Different Ways to fix Cannot resolve symbol ‘AppCompatActivity’ in Android Studio

When you create a project and extends activity AppCompatActivity, sometimes you must have observed Android Studio throws an error that is:

Cannot resolve symbol ‘AppCompatActivity’

and this error doesn’t go away easily. In this article, we are going to cover topics: why there is a need to solve this error and five different ways to get rid of this error.

Why There is a Need To Solve “Cannot resolve symbol ‘AppCompatActivity’”?

When you rename the application package name this error pops up. The import statement turns gray and says there’s no package for support.v7.app. Even after upgrading to appcompat-v7:22.1.0, in which AppCompatActivty (To get the most out of the Android Support Library that is, to get the latest features supported across the highest number of devices, we need AppCompatActivity) is added, the problem doesn’t go away. So we need to try the following methods to fix this problem in Android Studio.

Читайте также:  Elm ffn для андроид

How To Solve “Cannot resolve symbol ‘AppCompatActivity’”?

Method 1

  • Go to your build.gradle(Module:app) file and in the dependencies section the appcompat one, you should see something like compile ‘com.android.support:appcompat-v7:XX.X.X’, change it to compile ‘com.android.support:appcompat-v7:XX.X.+’ or else hit ALT + ENTER on both appcompat & design dependencies then select the shown version.
  • Then click on Sync.

Method 2

Navigate to File > Invalidate Caches/Restart and then disable offline mode and sync.

Method 3

Step 1: Delete the .idea folder. For .idea folder navigate to YourProject > app > .idea

Step 2: Close and reopen the project

Step 3: File > Sync Project With Gradle Files

Источник

Оцените статью