saichandu415 / MNS-Android-Sample

This is the sample project created to demonstrate the usage of Alibaba Cloud Messaging and Notification Services.
Apache License 2.0
1 stars 1 forks source link

Getting Run time Exception #1

Closed RajappaR closed 6 years ago

RajappaR commented 6 years ago

`Information:Gradle tasks [:app:assembleDebug] Error:trouble processing "javax/xml/bind/Binder.class": Error:Ill-advised or mistaken usage of a core class (java. or javax.) Error:when not building a core library. Error:This is often due to inadvertently including a core library file Error:in your application's project, when using an IDE (such as Error:Eclipse). If you are sure you're not intentionally defining a Error:core class, then this is the most likely explanation of what's Error:going on. Error:However, you might actually be trying to define a class in a core Error:namespace, the source of which you may have taken, for example, Error:from a non-Android virtual machine project. This will most Error:assuredly not work. At a minimum, it jeopardizes the Error:compatibility of your app with future versions of the platform. Error:It is also often of questionable legality. Error:If you really intend to build a core library -- which is only Error:appropriate as part of creating a full virtual machine Error:distribution, as opposed to compiling an application -- then use Error:the "--core-library" option to suppress this error message. Error:If you go ahead and use "--core-library" but are in fact Error:building an application, then be forewarned that your application Error:will still fail to build or run, at some point. Please be Error:prepared for angry customers who find, for example, that your Error:application ceases to function once they upgrade their operating Error:system. You will be to blame for this problem. Error:If you are legitimately using some code that happens to be in a Error:core package, then the easiest safe alternative you have is to Error:repackage that code. That is, move the classes in question into Error:your own package namespace. This means that they will never be in Error:conflict with core system classes. JarJar is a tool that may help Error:you in this endeavor. If you find that you cannot do this, then Error:that is an indication that the path you are on will ultimately Error:lead to pain, suffering, grief, and lamentation. Error:1 error; aborting Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process Information:BUILD FAILED in 57s Information:34 errors Information:0 warnings Information:See complete output in console`

saichandu415 commented 6 years ago

Try the below steps and update on the further issues.


switch your project view to Project in your Android Studio.

Go to the libs subfolder located under app folder, and copy the two libraries – aliyun-sdk-mns-1.1.18.jar & Jaxb-api.2.2.12.jar. Right click the libs folder and you will see the option "Add to Library". Go to your app build.gradle file then copy the below

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        // your Pacakge Name
        applicationId "sample.alibabacloud.notificationdemo"
        // your min sdk version
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    // make sure to include this for your jars compilation
    packagingOptions {

        exclude 'META-INF/DEPENDENCIES'
    }
    useLibrary 'org.apache.http.legacy'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.android.support:design:26.1.0'
    // Make sure you download dependency for multidex
    compile 'com.android.support:multidex:1.0.2'
    implementation files('libs/aliyun-sdk-mns-1.1.8.jar')
    implementation files('libs/jaxb-api-2.2.12.jar')
}

11.Enable multidex in your custom application class. Then, add this application class to AndroidManifest.xml

package sample.alibabacloud.notificationdemo;

import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.support.multidex.MultiDex;

/**
 * Created by Sarath Chandra
 */

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        startService(new Intent(this,ReceiveService.class));
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }
}
RajappaR commented 6 years ago

Thanks for the help