vaenow / cordova-plugin-app-update

App updater for Cordova/PhoneGap
MIT License
299 stars 146 forks source link

corodva build android ERROR: android.support.v4 #17

Open hefanhappy opened 7 years ago

hefanhappy commented 7 years ago

缺少support包,编译通不过,希望添加support包依赖

vaenow commented 7 years ago

是不是缺少这个包? android-support-v4.jar

请把具体的日志信息贴出来。

twothirdsFR commented 7 years ago

I think I have the same problem. The plugin does not compile, I have an error which is:

D:\xxxxxxx\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:6: error: package android.support.v4.app does not exist

When I launch "cordova run android". It looks like you are talking about a package that I am lacking.

twothirdsFR commented 7 years ago

I think I found a solution to my problem. I will explain it in english, because, you know, we are on the internet and we need to understand each other: you just need to install a plugin which will add a "android.support.v4.jar" which seems to be needed for this plugin. I found a plugin which does that: https://www.npmjs.com/package/cordova-plugin-android-support-v4

A simple "cordova plugin add cordova-plugin-android-support-v4 " will do the trick.

vaenow commented 7 years ago

Congratulations for your success build. :golf:

Another way: you can put this file android-support-v4.jar into directory: xxxxx/platforms/android/libs/

hefanhappy commented 7 years ago

config.xml add <framework src="com.android.support:support-v4:23.3.0+" />``

mideon commented 7 years ago

Hi, after adding cordova plugin add cordova-plugin-android-support-v4 the problem is still exist and when trying to build get following

Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. F:\projects\phonegap\test\intexcom\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:52: error: cannot find symbol int permission = ActivityCompat.checkSelfPermission(activity, ^ symbol: method checkSelfPermission(Activity,String) location: class ActivityCompat

my cordova version is 6.4.0 Java JDK: installed 1.8.0 Android SDK: installed true Android target: installed android-14,android-16,android-17,android-18,android-19,android-20,android-21,android-23,android-24,Google Inc.:Google APIs:16,Google Inc.:Google APIs:17,Google Inc.:Google APIs:18,Google Inc.:Google APIs:19,Google Inc.:Google APIs:21,Google Inc.:Google APIs:23 Gradle: installed <engine name="android" spec="~6.0.0" /> <framework src="com.android.support:support-v4:23.3.0+" /> <plugin name="cordova-plugin-whitelist" spec="~1.3.0" /> <plugin name="cordova-plugin-android-support-v4" spec="~21.0.1" /> <plugin name="cordova-plugin-app-update" spec="~1.3.9" />

adding <framework src="com.android.support:support-v4:23.3.0+" /> to config.xml didnt help me

mideon commented 7 years ago

Resolved, problem that https://www.npmjs.com/package/cordova-plugin-android-support-v4 doesnt help after installing it, I change android-support-v4.jar at platform/android/lib to file from %ANDROID_PATH%/extras/android/support/v4 and now it works

PS: I have not seen folder extras/android/support/v4 before cause i did'nt install Android Support Library at Android SDK Manager, for now it Obsollete for SDK and to show it at Extra folder need mark Obsolete checkbox under Show label . For more details look at http://startandroid.ru/images/stories/lessons/L0114/L0114_010.JPG

vaenow commented 7 years ago

@mideon Good job 😄 👍

badaay commented 7 years ago

I think getting same error in here,

how to fix this?

Error: cmd: Command failed with exit code 1 Error output:
C:\Users\.......\Myproject\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:6: error: package android.support.v4.app does not exist
import android.support.v4.app.ActivityCompat;
                             ^
C:\Users\.......\Myproject\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:52: error: cannot find symbol
        int permission = ActivityCompat.checkSelfPermission(activity,
                         ^
  symbol:   variable ActivityCompat
  location: class CheckAppUpdate
C:\Users\.......\Myproject\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:57: error: cannot find symbol
            ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
            ^
  symbol:   variable ActivityCompat
  location: class CheckAppUpdate
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.
vaenow commented 7 years ago

@badaay this issue maybe relate to the Pull #16

badaay commented 7 years ago

@vaenow i think , in my case this plugin still not working in android 6.x and later

dayaki commented 7 years ago

Please this problem is still there. Even after following all the instructions in this thread. the folder path %ANDROID_PATH%/extras/android/support/v4 no longer available. Any solution please

chaosnote commented 7 years ago

https://cordova.apache.org/docs/en/6.x/plugin_ref/spec.html#framework

  1. update ur android support repository(or library) like ... http://startandroid.ru/images/stories/lessons/L0114/L0114_010.JPG

  2. add below to plugin.xml <platform name="android"> ... <framework src="com.android.support:support-v4:+" /> ... </platform>

zhanyingfeng commented 7 years ago

platforms/android/project.properties 文件中加入 cordova.system.library.1=com.android.support:support-v4:+ cordova.system.library.2=com.android.support:support-v4:24.1.1+ 然后编译就可以了

Hodes commented 6 years ago

For me adding the plugin that @twothirdsFR mentioned worked too (plugin "cordova-plugin-android-support-v4"). As I'm working with Ionic v3.7.1 and following the patterns, I can't make what @hhafeng mentioned because that file will not be tracked by version control system (Although I tried and that worked).

ctpaula commented 6 years ago

I posted my problem above some days ago... Tried and resolved this by removing the android platform, then deleting everything from "..\node_modules", then deleting everything from "..\plugins" then cleaned "config.xml" and "package.json" of my project leaving only the plugins I needed, removed "cordova-plugin-android-support-v4" and leaved "cordova-plugin-local-notification" only. Then I executed "npm install", "ionic cordova platform add android" and the build works.


People, I need help to solve this problem on an Ionic project that I tried but could not solve it alone. When I build it I receive the following messages:

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:32: error: package android.support.v4.media.app.NotificationCompat does not exist
import android.support.v4.media.app.NotificationCompat.MediaStyle;
                                                      ^
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:130: error: cannot find symbol
                .setChannelId(options.getChannel())
                ^
  symbol:   method setChannelId(String)
  location: class Builder
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:296: error: cannot find symbol
        MediaStyle style;
        ^
  symbol:   class MediaStyle
  location: class Builder
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:298: error: cannot find symbol
        style = new MediaStyle(builder)
                    ^
  symbol:   class MediaStyle
  location: class Builder
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:417: error: constructor Builder in class Builder cannot be applied to given types;
            builder = new NotificationCompat.Builder(context, options.getChannel());
                      ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
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.
5 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':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.
:compileDebugJavaWithJavac FAILED

BUILD FAILED

Total time: 1 mins 6.871 secs
Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:32: error: package android.support.v4.media.app.NotificationCompat does not exist
import android.support.v4.media.app.NotificationCompat.MediaStyle;
                                                      ^
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:130: error: cannot find symbol
                .setChannelId(options.getChannel())
                ^
  symbol:   method setChannelId(String)
  location: class Builder
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:296: error: cannot find symbol
        MediaStyle style;
        ^
  symbol:   class MediaStyle
  location: class Builder
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:298: error: cannot find symbol
        style = new MediaStyle(builder)
                    ^
  symbol:   class MediaStyle
  location: class Builder
C:\Dev_Tortoise\AppBarigui\platforms\android\src\de\appplant\cordova\plugin\notification\Builder.java:417: error: constructor Builder in class Builder cannot be applied to given types;
            builder = new NotificationCompat.Builder(context, options.getChannel());
                      ^
  required: Context
  found: Context,String
  reason: actual and formal argument lists differ in length
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.
5 errors

FAILURE: Build failed with an exception.

I tried to add to

<plugin name="cordova-plugin-android-support-v4" spec="21.0.1" />

Tried to add in the package.json:

"dependencies": {
    "cordova-plugin-android-support-v4": "21.0.1",
...
},
...
"cordova": {
    "plugins": {
        "cordova-plugin-android-support-v4": {},
        ...
    }
}

Tried to remove android platform, added again.

Someone can help with the problem? Tell me if I need to remove something from config.xml or package.json... or if I need to add something else... I'm kinda beginner, so please tell step by step... Thanks!!

I'm using:

cli packages: (C:\Users\cristopherl\AppData\Roaming\npm\node_modules)
    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1
global packages:
    cordova (Cordova CLI) : 7.1.0
local packages:
    @ionic/app-scripts : 3.1.7
    Cordova Platforms  : android 6.3.0
    Ionic Framework    : ionic-angular 3.9.2
flight9 commented 6 years ago

same problem with Cordova 7.0.1, I've tried installed 'cordova-plugin-android-support-v4', remove and re-add platform android, and still got build problem:

:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
D:\Cordova\cdvupdate\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:52: 锟斤拷锟斤拷: 锟揭诧拷锟斤拷锟斤拷锟斤拷
        int permission = ActivityCompat.checkSelfPermission(activity,
                                       ^
  锟斤拷锟斤拷:   锟斤拷锟斤拷 checkSelfPermission(Activity,String)
  位锟斤拷: 锟斤拷 ActivityCompat
D:\Cordova\cdvupdate\platforms\android\src\com\vaenow\appupdate\android\CheckAppUpdate.java:57: 锟斤拷锟斤拷: 锟揭诧拷锟斤拷锟斤拷锟斤拷
            ActivityCompat.requestPermissions(activity, PERMISSIONS_STORAGE,
                          ^
  锟斤拷锟斤拷:   锟斤拷锟斤拷 requestPermissions(Activity,String[],int)
  位锟斤拷: 锟斤拷 ActivityCompat
2 锟斤拷锟斤拷锟斤拷
:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.