Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application crashes even if I haven't used KontaktCloud SDK #131

Closed
vegax87 opened this issue Oct 17, 2016 · 10 comments
Closed

Application crashes even if I haven't used KontaktCloud SDK #131

vegax87 opened this issue Oct 17, 2016 · 10 comments

Comments

@vegax87
Copy link

vegax87 commented Oct 17, 2016

I'm following the quickstart tutorials to build a simple app with KontaktSDK.initialize("MY-API-KEY"); compiling is ok, but when I start my app on my tablet (Android 4.4), it crashes..

java.lang.NoClassDefFoundError: okhttp3.OkHttpClient$Builder
at com.kontakt.sdk.android.cloud.KontaktCloud.buildHttpClient(KontaktCloud.java:190)
at com.kontakt.sdk.android.cloud.KontaktCloud.(KontaktCloud.java:88)
at com.kontakt.sdk.android.cloud.KontaktCloud.newInstance(KontaktCloud.java:73)
at com.kontakt.sdk.android.ble.manager.internal.InternalProximityManager.(InternalProximityManager.java:55)
at com.kontakt.sdk.android.ble.manager.ProximityManager.(ProximityManager.java:39)
at beacon.opendax.com.testbeacon.MainActivity.onCreate(MainActivity.java:67)
at android.app.Activity.performCreate(Activity.java:5458)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2470)
at android.app.ActivityThread.access$900(ActivityThread.java:174)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5593)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)

My permissions in AndroidManifest.xml:

uses-permission android:name="android.permission.BLUETOOTH"
uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
uses-permission android:name="android.permission.REAL_GET_TASKS"

uses-feature android:name="android.hardware.bluetooth_le" android:required="true"

@michaldrabik
Copy link
Contributor

@vegax87 Could it be connected with THIS issue? Are you using multidexing?

If not then please share some more code. Possibly your whole 'AndroidManifest' and 'build.gradle'.

Regards

@vegax87
Copy link
Author

vegax87 commented Oct 17, 2016

My build.gradle script, I used flatDir to import all java libraries in a single folder:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.1'
}
}

allprojects {
repositories {
jcenter()
flatDir {
dirs "$rootProject.projectDir/libs"
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

@vegax87
Copy link
Author

vegax87 commented Oct 17, 2016

My AndroidManifest.xml

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.REAL_GET_TASKS"/>

<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

@michaldrabik
Copy link
Contributor

michaldrabik commented Oct 17, 2016

@vegax87 I'm actually interested in a file that your dependencies are defined in (the one where you put com.kontaktio:sdk:3.1.1)

@vegax87
Copy link
Author

vegax87 commented Oct 17, 2016

I've already tried to add in build.gradle:

dependencies {
compile 'com.kontaktio:sdk:3.1.1'
}

but it displays this error in Android Studio:

Error:(9, 0) Could not find method compile() for arguments [com.kontaktio:sdk:3.1.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

@michaldrabik
Copy link
Contributor

@vegax87 If your project is just a small sample app than would you mind sharing it (via Google Drive or anything else could be email) with me as a ZIP or RAR file. It will be much easier for me to just try to run it on my computer and my Android devices to see whats going on.

@vegax87
Copy link
Author

vegax87 commented Oct 17, 2016

what's your email?

@michaldrabik
Copy link
Contributor

Use the one from my Github profile: m.drabik@kontakt.io

@michaldrabik
Copy link
Contributor

@vegax87 Thanks, I will check it out and get back to you when I can.

@michaldrabik
Copy link
Contributor

michaldrabik commented Oct 18, 2016

@vegax87 I've managed to track and fix the problem. The issue was that you used JAR file and not gradle dependency. SDK needs to see some sub-dependencies (like Retrofit or GSON). So you either need to download these JARS and also include them in your project or just use Gradle dependency for our SDK and let Gradle take care of this for you.

I've sent you back your project where I added misssing JARs for you. It's working just fine.

This information should be included in our documentation. Sorry for that. We will add it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants