Closed truongvu2106 closed 6 years ago
I have the same error ..
try Source Compatibility, Target Compatibility set 1.6
i have same error
any updates?
@sherlockat it work correctly
Thank you
I am facing the same problem. I just created a blank ionic app with this plugin installed, building for android gives a lot of cannot find symbol errors. Any help will be greatly appreciated.
Finally found it, @sherlockat was correct. Altought it took me some time to find out where you could change that.
It's found in /platforms/android/app/build.gradle
set the following values:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
@sherlockat When I set the above compile options, I am getting the following warning while building..
app/build.gradle compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 }
--Warnings app:transformClassesWithDexBuilderForDebug warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.LogFactory$6) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (org.apache.commons.logging.impl.LogFactoryImpl$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is not an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class
When I try the release build it fails with the following error
--Build ionic cordova build android --prod --release
--Error Execution failed for task ':app:transformClassesWithPreDexForRelease'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\ramesh.gradle\caches\modules-2\files-2.1\xpp3\xpp3\1.1.4c\9b988ea84b9e4e9f1874e390ce099b8ac12cfff5\xpp3-1.1.4c.jar' to 'C:\Code\OceanNet\OceanNetApp\platforms\android\app\build\intermediates\transforms\preDex\release\24.jar'
--android gradle project.ext { defaultBuildToolsVersion="25.0.2" //String defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4 defaultTargetSdkVersion=26 //Integer - We ALWAYS target the latest by default defaultCompileSdkVersion=26 //Integer - We ALWAYS compile with the latest by default }
--app gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
Hi,
Same here. Any update, please ?
I'm on macOS Sierra, with JAVA 1.8.0_131, Cordova 8.0.0, Ionic 3.19.1. Reproduceable by creating new Ionic project, then simply install this background-geolocation plugin, then build.
Using platform android@6.4.0, apparently the source and targetCompatibility is set to VERSION_1_6 ( hence compilation is OK ), while if using platform android@7.0.0, they are set to VERSION_1_8 ( which are causing those missing symbol compilation errors ).
Changing them to VERSION_1_6, compilation becomes OK, DEBUG APK build also OK, but then RELEASE APK build always having failure as shown below.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformClassesWithPreDexForRelease'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex '/Users/osx/.gradle/caches/modules-2/files-2.1/xerces/xmlParserAPIs/2.6.2/65acede1e5305bd2b92213d7b5761328c6f4fd9/xmlParserAPIs-2.6.2.jar' to '/Users/osx/Desktop/Dev/MyIonicProject/platforms/android/build/intermediates/transforms/preDex/release/23.jar'
Been also trying to add the following into build.gradle, where it's going a bit further, but then it still left me with one last error that I still haven't figured out what to exclude. See log below.
configurations {
all {
exclude module: 'httpclient'
exclude module: 'commons-logging'
exclude module: 'opengl-api'
exclude group: 'xpp3'
exclude group: 'xerces'
}
}
dexOptions {
additionalParameters=['--core-library']
}
:lintVitalRelease/Users/osx/Desktop/Dev/MyIonicProject/platforms/android/build.gradle:20: Error: android defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
apply plugin: 'com.android.application'
~~~~~~~
Explanation for issues of type "DuplicatePlatformClasses":
There are a number of libraries that duplicate not just functionality of
the Android platform but using the exact same class names as the ones
provided in Android -- for example the apache http classes. This can lead
to unexpected crashes.
To solve this, you need to either find a newer version of the library which
no longer has this problem, or to repackage the library (and all of its
dependencies) using something like the jarjar tool, or finally, rewriting
the code to use different APIs (for example, for http code, consider using
HttpUrlConnection or a library like okhttp.)
1 errors, 0 warnings
:assembleRelease
:cdvBuildRelease
Any help is really appreciate it as now I'm unable to build my release APK, until this got resolved.
Thank you.
Same issue for me... Thank you for your help.
The workaround in logtofile.gradle : dependencies { compile 'com.github.tony19:logback-android-core:1.1.1-6' compile('com.github.tony19:logback-android-classic:1.1.1-6') { exclude group: 'com.google.android', module: 'android' } compile 'org.slf4j:slf4j-api:1.7.21' }
@TraceDeTrail Nice fix. This was killing me. Thanks a ton!
@TraceDeTrail Thanks for your response. Where do I find the logtofile.gradle? Shall we do your fix instead of setting the compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 targetCompatibility JavaVersion.VERSION_1_6 } in app/build.gradle?
Thanks verymuch for your help.
I could not do a release build with cordova-android 6.4.0 when this plugin was installed due to some preDex error that i don't really understand that had something to do with: javax/xml/parsers/DocumentBuilder.class
I upgraded to cordova-android 7.0.0 and applied @TraceDeTrail workaround. Now everything builds perfectly in both debug and release mode.
Thanks a lot!
As mentioned in https://github.com/mauron85/react-native-background-geolocation/issues/131 this is actually logback issue.
Edit: Link to issue https://github.com/tony19/logback-android/issues/73
@TraceDeTrail ..woow.. was loosing mind over this. Solved
I ran into this issue as well, excited to see it might be fixed! Will test out the new alpha tonight.
Edit: Confirmed to fix the problem for me.
or Upgrade the logback-android
to 1.1.1-9
to build:
dependencies {
compile 'com.github.tony19:logback-android:1.1.1-9'
compile 'org.slf4j:slf4j-api:1.7.21'
}
@mauron85
As mentioned in mauron85/react-native-background-geolocation#131 this is actually logback issue. Edit: Link to issue tony19/logback-android#73
Tony has closed the issue. Would this be updated in the 2.x branch?
@yuriploc i really recommend you to migrate to 3.x version. Even it's labeled alpha, it's already in better condition then 2.x
Closing
where iss logtofile.gradle
I run cordova build tasks = am.getAppTasks();
^
symbol: class AppTask
location: class BackgroundExt
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\BackgroundExt.java:161: error: cannot find symbol
List tasks = am.getAppTasks();
^
symbol: method getAppTasks()
location: variable am of type ActivityManager
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\ForegroundService.java:164: error: cannot find symbol
Notification.Builder notification = new Notification.Builder(context)
^
symbol: class Builder
location: class Notification
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\ForegroundService.java:164: error: cannot find symbol
Notification.Builder notification = new Notification.Builder(context)
^
symbol: class Builder
location: class Notification
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\ForegroundService.java:171: error: cannot find symbol
notification.setPriority(Notification.PRIORITY_MIN);
^
symbol: variable PRIORITY_MIN
location: class Notification
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\ForegroundService.java:176: error: cannot find symbol
new Notification.BigTextStyle().bigText(text));
^
symbol: class BigTextStyle
location: class Notification
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\io\ionic\keyboard\IonicKeyboard.java:89: error: cannot find symbol
display.getSize(size);
^
symbol: method getSize(Point)
location: variable display of type Display
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\org\apache\cordova\device\Device.java:132: error: cannot find symbol
String serial = android.os.Build.SERIAL;
^
symbol: variable SERIAL
location: class Build
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\org\apache\cordova\splashscreen\SplashScreen.java:290: error: cannot find symbol
LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
^
symbol: variable MATCH_PARENT
location: class LayoutParams
E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\org\apache\cordova\splashscreen\SplashScreen.java:290: error: cannot find symbol
LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
^
symbol: variable MATCH_PARENT
location: class LayoutParams
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.
50 errors
ionic cordova build android --prod
and get error below ` E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:563: error: cannot find symbol @TargetApi(Build.VERSION_CODES.KITKAT) ^ symbol: variable KITKAT location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\BackgroundExt.java:153: error: cannot find symbol @TargetApi(Build.VERSION_CODES.LOLLIPOP) ^ symbol: variable LOLLIPOP location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\LocationService.java:189: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { ^ symbol: variable JELLY_BEAN_MR2 location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\LocationService.java:190: error: cannot find symbol handlerThread.quitSafely(); ^ symbol: method quitSafely() location: variable handlerThread of type HandlerThread E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\LocationService.java:198: error: method does not override or implement a method from a supertype @Override ^ E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\LocationService.java:207: error: cannot find symbol super.onTaskRemoved(rootIntent); ^ symbol: method onTaskRemoved(Intent) E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\LocationService.java:421: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ^ symbol: variable HONEYCOMB location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\LocationService.java:422: error: cannot find symbol task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, location); ^ symbol: variable THREAD_POOL_EXECUTOR location: class AsyncTask E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:55: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { ^ symbol: variable JELLY_BEAN_MR1 location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:56: error: cannot find symbol elapsedRealtimeNanos = location.getElapsedRealtimeNanos(); ^ symbol: method getElapsedRealtimeNanos() location: variable location of type Location E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:58: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { ^ symbol: variable JELLY_BEAN_MR2 location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:59: error: cannot find symbol isFromMockProvider = location.isFromMockProvider(); ^ symbol: method isFromMockProvider() location: variable location of type Location E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:567: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { ^ symbol: variable JELLY_BEAN_MR1 location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:568: error: cannot find symbol l.setElapsedRealtimeNanos(elapsedRealtimeNanos); ^ symbol: method setElapsedRealtimeNanos(long) location: variable l of type Location E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\BackgroundLocation.java:592: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { ^ symbol: variable JELLY_BEAN_MR1 location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\sqlite\SQLiteLocationDAO.java:113: error: method queryNumEntries in class DatabaseUtils cannot be applied to given types; return DatabaseUtils.queryNumEntries(db, LocationEntry.TABLE_NAME, whereClause, whereArgs); ^ required: SQLiteDatabase,String found: SQLiteDatabase,String,String,String[] reason: actual and formal argument lists differ in length E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\sqlite\SQLiteLocationDAO.java:154: error: cannot find symbol db.beginTransactionNonExclusive(); ^ symbol: method beginTransactionNonExclusive() location: variable db of type SQLiteDatabase E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\sqlite\SQLiteOpenHelper.java:118: error: cannot find symbol Log.d(TAG, "Creating db: " + this.getDatabaseName()); ^ symbol: method getDatabaseName() E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\data\sqlite\SQLiteOpenHelper.java:172: error: method does not override or implement a method from a supertype @Override ^ E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\HttpPostService.java:59: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ^ symbol: variable KITKAT location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\sync\BatchManager.java:70: error: cannot find symbol db.beginTransactionNonExclusive(); ^ symbol: method beginTransactionNonExclusive() location: variable db of type SQLiteDatabase E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\sync\SyncAdapter.java:71: error: constructor AbstractThreadedSyncAdapter in class AbstractThreadedSyncAdapter cannot be applied to given types; super(context, autoInitialize, allowParallelSyncs); ^ required: Context,boolean found: Context,boolean,boolean reason: actual and formal argument lists differ in length E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\marianhello\bgloc\sync\SyncService.java:60: error: cannot find symbol settingsBundle.putBoolean(ContentResolver.SYNC_EXTRAS_DO_NOT_RETRY, false); ^ symbol: variable SYNC_EXTRAS_DO_NOT_RETRY location: class ContentResolver E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:148: error: cannot find symbol criteria.setHorizontalAccuracy(translateDesiredAccuracy(config.getDesiredAccuracy())); ^ symbol: method setHorizontalAccuracy(Integer) location: variable criteria of type Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:166: error: cannot find symbol if (provider != LocationManager.PASSIVE_PROVIDER) { ^ symbol: variable PASSIVE_PROVIDER location: class LocationManager E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:187: error: cannot find symbol accuracy = Criteria.ACCURACY_LOW; ^ symbol: variable ACCURACY_LOW location: class Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:190: error: cannot find symbol accuracy = Criteria.ACCURACY_MEDIUM; ^ symbol: variable ACCURACY_MEDIUM location: class Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:193: error: cannot find symbol accuracy = Criteria.ACCURACY_HIGH; ^ symbol: variable ACCURACY_HIGH location: class Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:196: error: cannot find symbol accuracy = Criteria.ACCURACY_HIGH; ^ symbol: variable ACCURACY_HIGH location: class Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:199: error: cannot find symbol accuracy = Criteria.ACCURACY_MEDIUM; ^ symbol: variable ACCURACY_MEDIUM location: class Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:463: error: cannot find symbol criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH); ^ symbol: variable ACCURACY_HIGH location: class Criteria E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\bgloc\DistanceFilterLocationProvider.java:467: error: cannot find symbol locationManager.requestSingleUpdate(criteria, singleUpdatePI); ^ symbol: method requestSingleUpdate(Criteria,PendingIntent) location: variable locationManager of type LocationManager E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:535: error: cannot find symbol activity.bindService(locationServiceIntent, mConnection, Context.BIND_IMPORTANT); ^ symbol: variable BIND_IMPORTANT location: class Context E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:569: error: cannot find symbol return getContext().registerReceiver(locationModeChangeReceiver, new IntentFilter(LocationManager.MODE_CHANGED_ACTION)); ^ symbol: variable MODE_CHANGED_ACTION location: class LocationManager E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:585: error: cannot find symbol Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); ^ symbol: variable ACTION_APPLICATION_DETAILS_SETTINGS location: class Settings E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:598: error: cannot find symbol if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { ^ symbol: variable KITKAT location: class VERSION_CODES E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:599: error: cannot find symbol locationMode = Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE); ^ symbol: variable LOCATION_MODE location: class Secure E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\com\tenforwardconsulting\cordova\BackgroundGeolocationPlugin.java:600: error: cannot find symbol return locationMode != Settings.Secure.LOCATION_MODE_OFF; ^ symbol: variable LOCATION_MODE_OFF location: class Secure E:\Mine\Projects\map-ionic\platforms\android\app\src\main\java\de\appplant\cordova\plugin\background\BackgroundExt.java:161: error: cannot find symbol ListFAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 25s (node:14172) [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. `
I don't know why to occur this issue Someone help me. Many thanks