Why can't java find twilio? - eclipse

I am using Eclipse with Gradle. Twilio is listed as dependency. All versions are up to date. Code referencing Gradle will not compile and returns error messages that the Twilio classes do not exist. Code online is frustratingly outdated. I'm hoping someone here can help.
The Code I am running is very basic:
package SendAndReceiveSms;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
public class SmsSender {
public static final String ACCOUNT_SID = "**Redacted**";
public static final String AUTH_TOKEN = "**Redacted**";
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Message message = Message.creator(
new PhoneNumber("**redacted**"),
new PhoneNumber("**redacted**"),
"Message testing.")
.create();
System.out.println(message.getSid());
//sendMessage("**redacted**");
}
public void sendMessage(String numToSend) {
String n = numToSend;
Message message = Message.creator(
new PhoneNumber(n),
new PhoneNumber("+**(redacted)**"),
"Message testing.")
.create();
System.out.println(message.getSid());
}
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.2-jre'
//compile group: "com.twilio.sdk", name: "twilio", version: "7.45.+"
//compile group: "com.sparkjava", name: "spark-core", version: "2.7.1"
//compile group: "org.slf4j", name: "slf4j-simple", version: "1.7.21"
implementation 'org.slf4j:slf4j-simple:1.7.+'
implementation 'com.sparkjava:spark-core:2.5.+'
implementation group: 'com.twilio.sdk', name: 'twilio', version: '8.11.0'
//implementation 'com.twilio.sdk:twilio:7.+'
// implementation 'com.twilio.sdk', name: 'twilio', version: '8.11.0'
//runtimeOnly group: 'com.twilio.sdk', name: 'twilio', version: '8.11.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
Error code in Terminal:
SmsSender.java:3: error: package com.twilio does not exist
import com.twilio.Twilio;
^
SmsSender.java:4: error: package com.twilio.rest.api.v2010.account does not exist
import com.twilio.rest.api.v2010.account.Message;
^
SmsSender.java:5: error: package com.twilio.type does not exist
import com.twilio.type.PhoneNumber;
^
SmsSender.java:12: error: cannot find symbol
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
^
symbol: variable Twilio
location: class SmsSender
SmsSender.java:13: error: cannot find symbol
Message message = Message.creator(
^
symbol: class Message
location: class SmsSender
SmsSender.java:14: error: cannot find symbol
new PhoneNumber("..."),
^
symbol: class PhoneNumber
location: class SmsSender
SmsSender.java:15: error: cannot find symbol
new PhoneNumber("..."),
^
symbol: class PhoneNumber
location: class SmsSender
SmsSender.java:13: error: cannot find symbol
Message message = Message.creator(
^
symbol: variable Message
location: class SmsSender
SmsSender.java:24: error: cannot find symbol
Message message = Message.creator(
^
symbol: class Message
location: class SmsSender
SmsSender.java:25: error: cannot find symbol
new PhoneNumber(n),
^
symbol: class PhoneNumber
location: class SmsSender
SmsSender.java:26: error: cannot find symbol
new PhoneNumber("..."),
^
symbol: class PhoneNumber
location: class SmsSender
SmsSender.java:24: error: cannot find symbol
Message message = Message.creator(
^
symbol: variable Message
location: class SmsSender
12 errors
error: compilation failed

I don't see any problem with your project setup. You can compare it to this reference project.
So, I suspect the problem you're seeing is related to how Eclipse imports Gradle projects. I'm not a regular Eclipse user but I did try it out for this question. When I imported the project in the above repo I saw import errors similar to yours. I was able to fix them by first telling Eclipse that this is a Gradle project (Project context menu > Configure > Add Gradle Nature) then refreshing the project (Project context menu > Gradle > Refresh Gradle Project). I got those steps from this answer. Then everything was working.

Related

How to resolve "Exception: Gradle task assembleDebug failed with exit code 1"?

Flutter Version: 2.6.0-12.0.pre.381
Dart Version: 2.15.0
Gradle version : distributionUrl=https://services.gradle.org/distributions/gradle-6.7-all.zip
In pubspec.yaml, I have these packages:
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
splashscreen: ^1.2.0
bottom_navy_bar:
cupertino_icons: ^1.0.2
image_picker: ^0.8.0+4
fluttertoast: ^8.0.7
shared_preferences: ^2.0.6
share: ^2.0.4
flutter_barcode_scanner: ^2.0.0-nullsafety.0
dropdown_search: ^1.0.0
syncfusion_flutter_pdfviewer:
ndialog: ^4.1.0
flutter_pdfview: ^1.0.4
http: ^0.13.3
dio: ^4.0.0
path_provider: ^2.0.3
downloads_path_provider_28: ^0.1.2
permission_handler: ^8.1.4+2
open_file: ^3.2.1
flutter_local_notifications: ^9.0.0
Same packages are working in another project.
Any suggestions on how to fix the problem. I think it is due to some error in build.graddle.
I have changed minSdkVersion and targetSdkVersion in build.gradle as follows:
minSdkVersion 23
targetSdkVersion 29
multiDexEnabled true
It is showing error while running the project:
Launching lib\main.dart on SM M205F in debug mode...
Running Gradle task 'assembleDebug'...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\downloads_path_provider_28-0.1.2\android\src\main\java\it\nplace\downloadspathprovider\DownloadsPathProviderPlugin.java uses or overrides 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.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\image_picker-0.8.4+2\android\src\main\java\io\flutter\plugins\imagepicker\ImagePickerDelegate.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:58: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:59: error: cannot find symbol
status = Environment.isExternalStorageManager()
^
symbol: method isExternalStorageManager()
location: class Environment
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:254: error: cannot find symbol
if (permission == PermissionConstants.PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:268: error: cannot find symbol
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && permission == PermissionConstants.PERMISSION_GROUP_MANAGE_EXTERNAL_STORAGE) {
^
symbol: variable R
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:270: error: cannot find symbol
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
^
symbol: variable ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION
location: class Settings
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:321: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
^
symbol: variable S
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:349: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:380: error: cannot find symbol
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
^
symbol: variable R
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionManager.java:384: error: cannot find symbol
return Environment.isExternalStorageManager()
^
symbol: method isExternalStorageManager()
location: class Environment
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:64: error: cannot find symbol
case Manifest.permission.MANAGE_EXTERNAL_STORAGE:
^
symbol: variable MANAGE_EXTERNAL_STORAGE
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:72: error: cannot find symbol
case Manifest.permission.BLUETOOTH_SCAN:
^
symbol: variable BLUETOOTH_SCAN
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:74: error: cannot find symbol
case Manifest.permission.BLUETOOTH_ADVERTISE:
^
symbol: variable BLUETOOTH_ADVERTISE
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:76: error: cannot find symbol
case Manifest.permission.BLUETOOTH_CONNECT:
^
symbol: variable BLUETOOTH_CONNECT
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:235: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasPermissionInManifest(context, permissionNames, Manifest.permission.MANAGE_EXTERNAL_STORAGE ))
^
symbol: variable R
location: class VERSION_CODES
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:235: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && hasPermissionInManifest(context, permissionNames, Manifest.permission.MANAGE_EXTERNAL_STORAGE ))
^
symbol: variable MANAGE_EXTERNAL_STORAGE
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:236: error: cannot find symbol
permissionNames.add(Manifest.permission.MANAGE_EXTERNAL_STORAGE);
^
symbol: variable MANAGE_EXTERNAL_STORAGE
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:259: error: cannot find symbol
String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_SCAN);
^
symbol: variable BLUETOOTH_SCAN
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:270: error: cannot find symbol
String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_ADVERTISE);
^
symbol: variable BLUETOOTH_ADVERTISE
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:281: error: cannot find symbol
String result = determineBluetoothPermission(context, Manifest.permission.BLUETOOTH_CONNECT);
^
symbol: variable BLUETOOTH_CONNECT
location: class permission
C:\flutter\.pub-cache\hosted\pub.dartlang.org\permission_handler-8.2.5\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:370: error: cannot find symbol
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && hasPermissionInManifest(context, null, permission )) {
^
symbol: variable S
location: class VERSION_CODES
20 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':permission_handler: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 44s
Exception: Gradle task assembleDebug failed with exit code 1
This is happing due to compileSdkVersion. Head over to android/app/build.gradle and change complieSdkVersion to 31.
android {
compileSdkVersion 31
...
}
In pubspec.yaml file :-
dependencies:
permission_handler: ^8.2.5
The error must be happening in versions 8.2.0 and onwards. If you still encounter some error then install a version less 8.2.0.
Faced the same issue and this is how i solved it:
First i removed permission_handler from my yaml file.
Then did a flutter clean.
In pubspec.yaml : I changed the version of the permission_handler plugin from 8.2.6 to:
permission_handler: ^8.2.0
Then In android/app/build.grale file:changed compile sdk version to 31.
I think that Build.VERSION_CODES.R is API Level 30 , so setting compileSdkVersion to 30 should fix the issue .
I changed permission_handler: ^8.1.4+2 with permission_handler: 6.0.0 in pubspec.yaml .Now project is working fine. Thanks for your assistance.

JAX-RS not responding at all (404)

I'm using Eclipse 2020-03, Gradle and Tomcat. all I did follows.
Installing gradle through eclipse marketplace.
making gradle project.
adding those on build.gradle dependencies
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.2-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.27'
compile group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.27'
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.27'
}
adding "rest" package on src/main/java
adding ApplicationConfig.java and RestApiService.java on rest package.
ApplicationConfig.java
package rest;
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
#ApplicationPath("/api")
public class ApplicationConfig extends Application {
#Override
public Map<String, Object> getProperties(){
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("jersey.config.server.provider.packages", "A_UnivG.rest");
return properties;
}
}
RestApiService.java
package rest;
import java.util.logging.Logger;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import Data.*;
#Path("/Data")
public class RestApiService {
Logger logger = Logger.getLogger("RestApiService");
IntegrationDAO dao = new IntegrationDAO();
#GET
#Path("hello")
#Produces(MediaType.TEXT_PLAIN)
public String getHello() {return "Hello";}
}
and when I try to request http://localhost:portnumber/A_UnivG/api/Data/hello it spits out only 404 error.
cannot figure out why.
My project works with plain jsp files. I have a JSP page which uses DAO Read but it works just fine. well, that shouldn't be a problem I just tried hello world and it doesn't work at all.

Project won't compile because of Android X

I've cloned a project on Github. It uses different plugins.
dependencies:
flutter:
sdk: flutter
cupertino_icons: 0.1.2
firebase_auth: 0.7.0
google_sign_in: 3.2.4
cloud_firestore: 0.8.2+3
image_picker: 0.4.12+1
shared_preferences: 0.4.3
firebase_storage: 1.0.4
cached_network_image: 0.7.0
intl: 0.15.7
There is blog post which advises keeping versions the same. My problem is the image_picker plugin. Looking around stackoverflow it recommends using version 0.4.12+1 if you don't want to migrate app to Android X. Here is my error
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java:8: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:15: error: package android.support.annotation does not exist
import android.support.annotation.VisibleForTesting;
^
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java:40: error: cannot find symbol
#VisibleForTesting
^
symbol: class VisibleForTesting
location: class ImagePickerPlugin
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:68: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_CHOOSE_IMAGE_FROM_GALLERY = 2342;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:69: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_TAKE_IMAGE_WITH_CAMERA = 2343;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:70: error: cannot find symbol
#VisibleForTesting static final int REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION = 2344;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:71: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CAMERA_IMAGE_PERMISSION = 2345;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:72: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_CHOOSE_VIDEO_FROM_GALLERY = 2352;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:73: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CODE_TAKE_VIDEO_WITH_CAMERA = 2353;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:74: error: cannot find symbol
#VisibleForTesting static final int REQUEST_EXTERNAL_VIDEO_STORAGE_PERMISSION = 2354;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:75: error: cannot find symbol
#VisibleForTesting static final int REQUEST_CAMERA_VIDEO_PERMISSION = 2355;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:77: error: cannot find symbol
#VisibleForTesting final String fileProviderName;
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
/Users/gerardhorgan/Downloads/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.4.12+1/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerDelegate.java:164: error: cannot find symbol
#VisibleForTesting
^
symbol: class VisibleForTesting
location: class ImagePickerDelegate
13 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':image_picker: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.
BUILD FAILED in 2s
*******************************************************************************************
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
*******************************************************************************************
Finished with error: Gradle task assembleDebug failed with exit code 1
I'm wondering what might be causing the incompatibilities prevent my app from compiling?
You need to flow the documentation for AndroidX compatibility
The best option is migrate the app for androidX. Follow the steps in android-studio:
1) Remove all your dependencies of your pubspec file and run flutter packages get
2) Open only android module of your app in android-studio. You can do this with right click on your project root directory > flutter > Open android module in android studio
3) After open only android module in android-studio menu go to Refactor > MigrateToAndoridX...
4) Do the migration!
5) Close android module android-studio instance and go back to your flutter project
6) Insert all your dependencies in pubspec file and run flutter packages get
Use image_picker: ^0.6.6+1 and add AndroidManifest.xml following:
<uses-permission android:name="android.permission.INTERNET"/>
This way worked for me!

React Native Map Box Execution Failed transform classes with Dex / JarMerging

I've just started using MapBox in react-native but I appear to be getting the following error
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
Enabling multidex with
multiDexEnabled true
I then get the following
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
Here's the config
build.gradle .../android
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
// Add jitpack repository (added by tipsi-stripe)
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
build.gradle ../app
dependencies {
compile project(':mapbox-react-native-mapbox-gl')
compile project(':react-native-branch')
compile project(':react-native-camera')
compile project(':tipsi-stripe')
compile project(':react-native-device-info')
compile project(':react-native-vector-icons')
compile project(':react-native-i18n')
compile project(':react-native-geocoder')
compile project(':react-native-fbsdk')
compile(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
exclude group: 'com.google.android.gms', module: 'play-services-maps'
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.google.android.gms:play-services-base:11.+'
compile 'com.google.android.gms:play-services-maps:11.+'
}
settings.gradle
include ':mapbox-react-native-mapbox-gl'
project(':mapbox-react-native-mapbox-gl').projectDir = new File(rootProject.projectDir, '../node_modules/#mapbox/react-native-mapbox-gl/android/rctmgl')
include ':react-native-branch'
project(':react-native-branch').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-branch/android')
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':tipsi-stripe'
project(':tipsi-stripe').projectDir = new File(rootProject.projectDir, '../node_modules/tipsi-stripe/android')
include ':react-native-device-info'
project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':react-native-i18n'
project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')
include ':react-native-geocoder'
project(':react-native-geocoder').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geocoder/android')
include ':react-native-fbsdk'
project(':react-native-fbsdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fbsdk/android')
include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')
include ':app'
MainApplication.java
import android.app.Application;
import android.content.Intent;
import com.facebook.CallbackManager;
import com.facebook.FacebookSdk;
import com.facebook.react.ReactApplication;
import com.mapbox.rctmgl.RCTMGLPackage;
import io.branch.rnbranch.RNBranchPackage;
import io.branch.referral.Branch;
import com.lwansbrough.RCTCamera.RCTCameraPackage;
import com.gettipsi.stripe.StripeReactPackage;
import com.learnium.RNDeviceInfo.RNDeviceInfo;
import com.oblador.vectoricons.VectorIconsPackage;
import com.i18n.reactnativei18n.ReactNativeI18n;
import com.devfd.RNGeocoder.RNGeocoderPackage;
import com.facebook.reactnative.androidsdk.FBSDKPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import com.airbnb.android.react.maps.MapsPackage;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private static CallbackManager mCallbackManager = CallbackManager.Factory.create();
protected static CallbackManager getCallbackManager() {
return mCallbackManager;
}
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
#Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
#Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RCTMGLPackage(),
new RNBranchPackage(),
new RCTCameraPackage(),
new StripeReactPackage(),
new RNDeviceInfo(),
new MapsPackage(),
new VectorIconsPackage(),
new ReactNativeI18n(),
new RNGeocoderPackage(),
new FBSDKPackage(mCallbackManager)
);
}
};
#Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
SoLoader.init(this, /* native exopackage */ false);
// initialize the Branch object
Branch.setPlayStoreReferrerCheckTimeout(0);
Branch.getAutoInstance(this);
}
}
Stacktrace
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
> com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
* Try:
Run with --info or --debug option to get more log output.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformDexArchiveWithDexMergerForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:55)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 27 more
Caused by: com.android.build.api.transform.TransformException: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:230)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:222)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:218)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
... 39 more
Caused by: com.android.dex.DexException: Multiple dex files define Lokhttp3/internal/ws/WebSocketReader;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:661)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:616)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:598)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:61)
at com.android.builder.dexing.DexArchiveMergerCallable.call(DexArchiveMergerCallable.java:36)
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
148 actionable tasks: 4 executed, 144 up-to-date
I'm not sure if this is a matter of my current project config or what not, but i've not seen reports of this so far.
Update with adding in workaround enables app to launch but then another issue arises: NoClassDefFoundError: com.google.android.gms.wallet.MaskedWalletRequest
I've now added in configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' } as suggested by https://github.com/facebook/react-native/issues/12646 which enables the app to build succesfully but then there is an issue of NoClassDefFoundError: com.google.android.gms.wallet.MaskedWalletRequest
Just to clarify moving over to mapbox, I'll no longer need react-native-maps, and the reason for the move over is the greater level of detail i.e. in the buildings.
Thanks, appreciate you're help
Looks like a similar issue was raised against the repo and can probably be resolved if you...
exclude android.arch.core module from the mapbox project
compile 'com.google.android.gms:play-services-base:11.+'
compile 'com.google.android.gms:play-services-maps:11.+`
Version for com.google.android.gms:play-services should be same in build.gradle for app. and and in build.gradle of your packages installed.
-Here 11.+ version refers to any version greater then 11 which currently
available.i would suggest to make this version static and copy that version in build.gradle of your package in node-modules which gives error.
it is necessary to have same com.google.android.gms:play-services version throughout the app
Thankfully I was finally able to get mapbox in on my android version in react-native after resolving issues that popped up along the way: First of all my first attempt was on an older version of react-native 0.44.0, I later upgraded to the latest version of react native
"react-native": "^0.50.3",
and using react
"react": "^16.1.1",
Error
* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
This was the first, the app exceeds the maximum number of methods so we go ahead and enable multiDex in app/gradle
android {
compileSdkVersion 25
defaultConfig {
...
multiDexEnabled true
The next issue was
* What went wrong:
Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class
One approach to resolving this was found to use on the older version of react-native but this was not required it seems on the most recent version following the upgrade with react-native-git-upgrade
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
Another issue that popped up was
Failed to resolve: android.arch.lifecycle:extension:1.0.0-alpha3
which was resolved by adding maven { url 'https://maven.google.com' } to
allprojects {
repositories {
jcenter()
mavenCentral()
maven { url 'https://maven.google.com' }
}
}
Then there was an Aapt exception error which was resolved by adding to gradle.properties
android.enableAapt2=false
The app would now build succesfully but on starting irrespective of whether upraded to the latest version or not would show the error
C++ Exception in 'NativeModules': java.lang.NoClassDefFoundError: com.google.android.gms.wallet.MaskedWalletRequest
which was resolved by adding
implementation 'com.google.android.gms:play-services-wallet:11.+'
to our gradle dependencies.
And then the app built and started succesfully with no errors.
I think upgrading to the latest version of react-native, react, helped a great deal with compatability, speed, and performance, as well as by using the latest version of gradle and for example when doing so
configurations.all { resolutionStrategy.force 'com.squareup.okhttp3:okhttp:3.4.1' }
was needed to be added assuming that conflict must have been resolved in a later version.
Anyway, hope this helps someone, and pleased to say I've finally got mapbox in the app.
Thanks to #nitaliano for helping out over at https://github.com/mapbox/react-native-mapbox-gl/issues/785, and providing guidance, a long with the references and help found on https://github.com/tipsi/tipsi-stripe/issues/18 https://github.com/facebook/react-native/issues/12646 https://github.com/mapbox/react-native-mapbox-gl/issues/767 and also the help from Chris Geirman and Rajat Gupta here.
The following references were also helpful
https://facebook.github.io/react-native/docs/upgrading.html
https://reactjs.org/blog/2017/04/07/react-v15.5.0.html
https://reactjs.org/blog/2017/09/26/react-v16.0.html
https://github.com/mlaursen/react-md/issues/325
https://www.npmjs.com/package/prop-types
https://github.com/mapbox/react-native-mapbox-gl/blob/master/example/src/App.js
https://github.com/mapbox/react-native-mapbox-gl/blob/master/example/src/components/ShowMap.js
Mapbox: Cant add LocationLayer plugin in gradle
https://github.com/tipsi/tipsi-stripe/issues/18
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
Thanks again 👍

"line number not found" error in confg/routes file in play2.3

my routes file in play gives this error
**error: cannot find symbol
In /home/smat/practical/Stocks/conf/routes (line number not found)**
here is my routes file
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~
# Home page
GET / controllers.Application.index
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path="/public", file)
# stocks
GET /stocks/add controllers.Stocks.add
POST /stocks/save controllers.Stocks.save
GET /register controllers.Stocks.registerUser
POST /register controllers.Stocks.registerUser
please help
sorry i forget to share errors on terminal
**[error] /home/smat/practical/Stocks/target/scala-2.11/src_managed/main/contrllers/routes.java:8:
error: cannot find symbol [error] public static final
contrllers.ReverseStocks Stocks = new contrllers.ReverseStocks();
[error] ^ [error] symbol: class
ReverseStocks [error] location: package contrllers
[error]
/home/smat/practical/Stocks/target/scala-2.11/src_managed/main/contrllers/routes.java:11:
error: package contrllers.javascript does not exist [error] public
static final contrllers.javascript.ReverseStocks Stocks = new
contrllers.javascript.ReverseStocks(); [error]
^ [error]
/home/smat/practical/Stocks/target/scala-2.11/src_managed/main/contrllers/routes.java:16:
error: package contrllers.ref does not exist [error] public static
final contrllers.ref.ReverseStocks Stocks = new
contrllers.ref.ReverseStocks(); [error]
^ [error]
/home/smat/practical/Stocks/target/scala-2.11/src_managed/main/contrllers/routes.java:8:
error: cannot find symbol [error] public static final
contrllers.ReverseStocks Stocks = new contrllers.ReverseStocks();
[error]
^ [error] symbol: class ReverseStocks [error] location: package
contrllers [error]
/home/smat/practical/Stocks/target/scala-2.11/src_managed/main/contrllers/routes.java:11:
error: package contrllers.javascript does not exist [error] public
static final contrllers.javascript.ReverseStocks Stocks = new
contrllers.javascript.ReverseStocks(); [error]
^ [error]
/home/smat/practical/Stocks/target/scala-2.11/src_managed/main/contrllers/routes.java:16:
error: package contrllers.ref does not exist [error] public static
final contrllers.ref.ReverseStocks Stocks = new
contrllers.ref.ReverseStocks(); [error]
^**
package contrllers.ref does not exist
It looks like you made a misspell somewhere in the source files. Try to lookup your project directories for files with "contrllers" instead of "controllers".