Vonage / vonage-java-sdk

Vonage Server SDK for Java. API support for SMS, Messages, Voice, Text-to-Speech, Numbers, Verify (2FA), Video and more.
https://developer.vonage.com/en/home
Apache License 2.0
96 stars 121 forks source link

More than one file was found with OS independent path 'META-INF/DEPENDENCIES' #128

Closed stevdza-san closed 6 years ago

stevdza-san commented 6 years ago

Hello there, recently I have been learning java(developing android applications). And I have decided to use your nexmo api in my new application, but when I inserted 'mavenCentral()' in build.gradle(project) and 'compile 'com.nexmo:client:3.1.0'' in build.gradle(Module) with provided java code, I got this message: Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

More than one file was found with OS independent path 'META-INF/DEPENDENCIES'

I don't know where it went wrong, or what I'm supposed to change. Any help? Thank you.

ChrisGuzman commented 6 years ago

Hey there! 👋

Glad to hear that you're using our API. I think I've seen that error before in other projects I've worked on. Have you tried any of the solutions in these stack overflow posts?

stevdza-san commented 6 years ago

I have fixed that I suppose, I don't have the same error anymore, thank you for that Chris. :) But now I'm getting runtime exception:

11-02 19:26:14.658 21020-21020/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.nexmodemo, PID: 21020 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.nexmodemo/com.nexmodemo.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.nexmodemo.MainActivity" on path: DexPathList[[zip file "/data/app/com.nexmodemo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.nexmodemo-1, /vendor/lib, /system/lib]] at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2174) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2298) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:212) at android.app.ActivityThread.main(ActivityThread.java:5151) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nexmodemo.MainActivity" on path: DexPathList[[zip file "/data/app/com.nexmodemo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.nexmodemo-1, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:497) at java.lang.ClassLoader.loadClass(ClassLoader.java:457) at android.app.Instrumentation.newActivity(Instrumentation.java:1061) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2165) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2298)  at android.app.ActivityThread.access$800(ActivityThread.java:144)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:212)  at android.app.ActivityThread.main(ActivityThread.java:5151)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:515)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)  at dalvik.system.NativeStart.main(Native Method)

AND, this is my MainActivity:

package com.nexmodemo;

import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import com.nexmo.client.NexmoClient; import com.nexmo.client.NexmoClientException; import com.nexmo.client.auth.TokenAuthMethod; import com.nexmo.client.sms.messages.TextMessage;

import java.io.IOException;

public class MainActivity extends AppCompatActivity {

private final String API_KEY = "mykey";
private final String API_SECRET = "mysecretkey";

String fromNumber = "+381....";
String toNumber = "+381....";
String message = "Hello from Nexmo";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    NexmoClient client = new NexmoClient(new TokenAuthMethod(API_KEY, API_SECRET));
    try {
        client.getSmsClient().submitMessage(new TextMessage(fromNumber,toNumber,message));
    } catch (IOException e) {
        e.printStackTrace();
    } catch (NexmoClientException e) {
        Log.e("ERROR", e.getMessage());
    }
}

}

ChrisGuzman commented 6 years ago

Did you add MainActivity to your AndroidManifest.xml?

Can I ask how you plan to use the nexmo-java library in your Android app? Most developers use the nexmo-java for their server side projects

stevdza-san commented 6 years ago

Yeah, MainActivity is automatically added in AndroidManifest by Android Studio. Well I wanted to make a job easier, to make few inputs for messaging like editText for: To, From, Message and one button to send the message, nothing special for personal use.

stevdza-san commented 6 years ago

If you have some sample project you can send me to check it out? Sorry for bothering you, but I'm pretty stubborn to make it work. New to the programming world, you know how it's like :)

judy2k commented 6 years ago

Hi @CyberWarriorZ - I think @ChrisGuzman has linked to some tutorials in your other issue.

The problems you're seeing are because the Nexmo client library is designed to be run on a server, not on an Android device. It's not something we had ever specifically tested, which is why you're having issues.

I totally understand what it's like to get started! If you want to get started with the Nexmo APIs (rather than getting started with Android specifically), check out our quickstart code or some of our blog posts will help you to get up and running.

stevdza-san commented 6 years ago

@judy2k Yes I understand what you are trying to say. Too bad that library is not designed for android applications, but who knows maybe in the future it will be. Thank you.