2016-04-25 10 views
1

Ich habe Adobe creative SDK in mein Projekt aufgenommen und erhalte nun einen Fehler, wenn ich versuche, zur Bildbearbeitungsfunktion zu wechseln.java.lang.NoClassDefFoundError: rx.subjects.PublishSubject

FATAL EXCEPTION: main 
       java.lang.NoClassDefFoundError: rx.subjects.PublishSubject 
       at com.adobe.creativesdk.aviary.internal.account.AdobeAccountConnection.<init>(AdobeAccountConnection.java:45) 
       at com.adobe.creativesdk.aviary.AdobeImageEditorActivity.onCreate(AdobeImageEditorActivity.java:517) 
       at android.app.Activity.performCreate(Activity.java:5268) 
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104) 
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2178) 
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2264) 
       at android.app.ActivityThread.access$600(ActivityThread.java:144) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1259) 
       at android.os.Handler.dispatchMessage(Handler.java:99) 
       at android.os.Looper.loop(Looper.java:137) 
       at android.app.ActivityThread.main(ActivityThread.java:5136) 
       at java.lang.reflect.Method.invokeNative(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:525) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:740) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
       at dalvik.system.NativeStart.main(Native Method) 

Ich ging den Dokumentationen durch, aber ich habe keine Ahnung, warum dieser Fehler im

ich meinen Code angebracht haben immer

package com.sliit.dailyselfie.Camera; 

import android.app.Dialog; 
import android.content.Context; 
import android.content.Intent; 
import android.content.res.Configuration; 
import android.graphics.Bitmap; 
import android.graphics.BitmapFactory; 
import android.graphics.Matrix; 
import android.media.ExifInterface; 
import android.net.Uri; 
import android.os.Bundle; 
import android.os.Environment; 
import android.provider.MediaStore; 
import android.support.annotation.IdRes; 
import android.support.design.widget.FloatingActionButton; 
import android.support.design.widget.Snackbar; 
import android.support.v4.content.ContextCompat; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.util.Log; 
import android.view.View; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.Window; 
import android.widget.Button; 
import android.widget.ImageButton; 
import android.widget.ImageView; 
import android.widget.TextView; 
import android.widget.Toast; 

import com.adobe.creativesdk.aviary.AdobeImageIntent; 
import com.bumptech.glide.Glide; 
import com.roughike.bottombar.BottomBar; 
import com.roughike.bottombar.OnMenuTabClickListener; 
import com.sliit.dailyselfie.R; 

import java.io.File; 
import java.io.IOException; 
import java.text.SimpleDateFormat; 
import java.util.Date; 

import rebus.bottomdialog.BottomDialog; 


public class CameraActivity extends AppCompatActivity { 

    private static final int ActivityStartCAM=0; 
    private final static int EDIT_IMAGE=1; 
    private ImageView IV; 
    private String ImageFileLoaction=""; 

    BottomBar CamBottomBar; 
    ImageButton bcan,bsnap,bdesc; 
    Dialog d; 
    BottomDialog dialog; 
    String challenge; 
    Bundle extras; 
    boolean picpresent=false; 

    Uri ImageUri; 






    @Override 
    protected void onCreate(final Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_camera); 
     Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
     setSupportActionBar(toolbar); 

     IV = (ImageView)findViewById(R.id.snap1); 

     IV.setOnLongClickListener(new View.OnLongClickListener() { 
      @Override 
      public boolean onLongClick(View v) { 


       if (picpresent) { 
        dialog = new BottomDialog(CameraActivity.this); 
        dialog.title("Options"); 
        dialog.canceledOnTouchOutside(true); 
        dialog.cancelable(true); 
        dialog.inflateMenu(R.menu.camera_bottomsheet_menu); 
        dialog.setOnItemSelectedListener(new BottomDialog.OnItemSelectedListener() { 
         @Override 
         public boolean onItemSelected(int id) { 
          switch (id) { 
           case R.id.addeffects: 
            image(); 
            return true; 

           case R.id.crop: 
            Toast.makeText(getApplicationContext(),"crop",Toast.LENGTH_SHORT).show(); 
            return true; 

           default: 
            return false; 
          } 
         } 
        }); 
        dialog.show(); 
       } 
       return true; 
      } 
     }); 


     extras = getIntent().getExtras(); 
     if (extras != null) { 
      challenge = extras.getString("Challenge"); 
     } 


     CamBottomBar = BottomBar.attach(this, savedInstanceState); 
     CamBottomBar.noNavBarGoodness(); 



     CamBottomBar.setItemsFromMenu(R.menu.camera_bottombar, new OnMenuTabClickListener() { 
      @Override 
      public void onMenuTabSelected(@IdRes int menuItemId) { 

       if (menuItemId == R.id.nav_back) { 

        IV.setImageResource(R.drawable.selfieimage); 
        IV.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 
        picpresent = false; 

       } else if (menuItemId == R.id.nav_takeSnap) { 
        Intent CAMint= new Intent(); 
        CAMint.setAction(MediaStore.ACTION_IMAGE_CAPTURE); 
        File photoFile=null; 
        try{ 
         photoFile=createImageFile(); 
        }catch(IOException e){ 
         e.printStackTrace(); 
        } 

        CAMint.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); 
        startActivityForResult(CAMint, ActivityStartCAM); 


       } else if (menuItemId == R.id.nav_addDetails) { 
        if (picpresent) { 

         switch (challenge) { 

          case "fitness": 
           d = new Dialog(CameraActivity.this); 
           d.requestWindowFeature(Window.FEATURE_NO_TITLE); 
           d.setContentView(R.layout.fitnessdialog); 
           ImageView fitim = (ImageView) d.findViewById(R.id.fitdialogimg); 
           TextView fittxt = (TextView) d.findViewById(R.id.fitdialogdesc); 
           d.show(); 
           break; 

          case "maternity": 
           d = new Dialog(CameraActivity.this); 
           d.requestWindowFeature(Window.FEATURE_NO_TITLE); 
           d.setContentView(R.layout.maternitydialog); 
           ImageView matimg = (ImageView) d.findViewById(R.id.matdialogimg); 
           TextView mattxt = (TextView) d.findViewById(R.id.matdialogdesc); 
           d.show(); 

           break; 

          case "child": 
           d = new Dialog(CameraActivity.this); 
           d.requestWindowFeature(Window.FEATURE_NO_TITLE); 
           d.setContentView(R.layout.childdialog); 
           ImageView chilimg = (ImageView) d.findViewById(R.id.childialogimg); 
           TextView chiltxt = (TextView) d.findViewById(R.id.childialogdesc); 
           d.show(); 

           break; 

         } 


        }else{ 
         Toast.makeText(CameraActivity.this, "Please select image", Toast.LENGTH_SHORT).show(); 
        } 

       } 
// 
//    CamBottomBar.mapColorForTab(0, ContextCompat.getColor(CameraActivity.this, R.color.bottomPrimary)); 
//    CamBottomBar.mapColorForTab(1, ContextCompat.getColor(CameraActivity.this, R.color.bottomPrimary)); 
//    CamBottomBar.mapColorForTab(2, ContextCompat.getColor(CameraActivity.this, R.color.bottomPrimary)); 


      } 

      @Override 
      public void onMenuTabReSelected(@IdRes int menuItemId) { 


       if (menuItemId == R.id.nav_back) { 

        IV.setImageResource(R.drawable.selfieimage); 
        IV.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 
        picpresent = false; 


       } else if (menuItemId == R.id.nav_takeSnap) { 
        Intent CAMint = new Intent(); 
        CAMint.setAction(MediaStore.ACTION_IMAGE_CAPTURE); 
        File photoFile = null; 
        try { 
         photoFile = createImageFile(); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 

        CAMint.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); 
        startActivityForResult(CAMint, ActivityStartCAM); 


       } else if (menuItemId == R.id.nav_addDetails) { 

        if (picpresent) { 

         switch (challenge) { 

          case "fitness": 
           d = new Dialog(CameraActivity.this); 
           d.requestWindowFeature(Window.FEATURE_NO_TITLE); 
           d.setContentView(R.layout.fitnessdialog); 
           ImageView fitim = (ImageView) d.findViewById(R.id.fitdialogimg); 
           TextView fittxt = (TextView) d.findViewById(R.id.fitdialogdesc); 
           d.show(); 
           break; 

          case "maternity": 
           d = new Dialog(CameraActivity.this); 
           d.requestWindowFeature(Window.FEATURE_NO_TITLE); 
           d.setContentView(R.layout.maternitydialog); 
           ImageView matimg = (ImageView) d.findViewById(R.id.matdialogimg); 
           TextView mattxt = (TextView) d.findViewById(R.id.matdialogdesc); 
           d.show(); 

           break; 

          case "child": 
           d = new Dialog(CameraActivity.this); 
           d.requestWindowFeature(Window.FEATURE_NO_TITLE); 
           d.setContentView(R.layout.childdialog); 
           ImageView chilimg = (ImageView) d.findViewById(R.id.childialogimg); 
           TextView chiltxt = (TextView) d.findViewById(R.id.childialogdesc); 
           d.show(); 

           break; 

         } 


        }else{ 
         Toast.makeText(CameraActivity.this, "Please select image", Toast.LENGTH_SHORT).show(); 
        } 

       } 

// 
//    CamBottomBar.mapColorForTab(0, ContextCompat.getColor(CameraActivity.this, R.color.bottomPrimary)); 
//    CamBottomBar.mapColorForTab(1, ContextCompat.getColor(CameraActivity.this, R.color.bottomPrimary)); 
//    CamBottomBar.mapColorForTab(2, ContextCompat.getColor(CameraActivity.this, R.color.bottomPrimary)); 


      } 
     }); 



    } 


    @Override 
    public void onConfigurationChanged(Configuration newConfig) { 
     super.onConfigurationChanged(newConfig); 
     rotateImage(setReducedImageSize()); 
     IV.setScaleType(ImageView.ScaleType.CENTER_CROP); 
     if(!picpresent){ 
      IV.setImageResource(R.drawable.selfieimage); 
      IV.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 
     } 
    } 

    public void TakePhoto(View v){ 
     Intent CAMint= new Intent(); 
     CAMint.setAction(MediaStore.ACTION_IMAGE_CAPTURE); 
     File photoFile=null; 
     try{ 
      photoFile=createImageFile(); 
     }catch(IOException e){ 
      e.printStackTrace(); 
     } 

     CAMint.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); 
     startActivityForResult(CAMint, ActivityStartCAM); 

    } 

    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if(requestCode==ActivityStartCAM && resultCode==RESULT_OK){ 
      rotateImage(setReducedImageSize()); 
      ImageUri = Uri.parse(ImageFileLoaction); 
      IV.setScaleType(ImageView.ScaleType.CENTER_CROP); 
      picpresent=true; 

     } 
     if (resultCode == RESULT_OK && requestCode==EDIT_IMAGE) { 


       /* Make a case for the request code we passed to startActivityForResult() */ 

        /* Show the image! */ 
      Uri editedImageUri = data.getData(); 
      ImageUri=data.getData(); 
      Glide.with(this).load(editedImageUri).into(IV); 
      picpresent=true; 



     } 

    } 

    File createImageFile()throws IOException{ 
     String timestamp= new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); 
     String imageFieldname="IMAGE "+timestamp+"_"; 
     File storageDeirectory= Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); 
     File image=File.createTempFile(imageFieldname,".jpg",storageDeirectory); 
     ImageFileLoaction=image.getAbsolutePath(); 
     return image; 
    } 

    private Bitmap setReducedImageSize(){ 
     int taretimagevieweidth=IV.getWidth(); 
     int targetimageviewheight=IV.getHeight(); 
     BitmapFactory.Options bmfop= new BitmapFactory.Options(); 
     bmfop.inJustDecodeBounds=true; 
     BitmapFactory.decodeFile(ImageFileLoaction,bmfop); 
     int Cameraheight=bmfop.outHeight; 
     int Camerawidth=bmfop.outWidth; 
     int scalefactor =Math.min(Camerawidth/taretimagevieweidth,Cameraheight/targetimageviewheight); 
     bmfop.inSampleSize=scalefactor; 
     bmfop.inJustDecodeBounds=false; 
     return BitmapFactory.decodeFile(ImageFileLoaction,bmfop); 
    } 

    private void rotateImage(Bitmap bitmap){ 
     ExifInterface exifInterface = null; 
     try{ 
      exifInterface = new ExifInterface(ImageFileLoaction); 
     }catch(Exception e){ 
      e.printStackTrace(); 
     } 
     int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION,ExifInterface.ORIENTATION_UNDEFINED); 
     Matrix matrix = new Matrix(); 
     switch (orientation){ 
      case ExifInterface.ORIENTATION_ROTATE_90: 
       matrix.setRotate(90); 
       break; 
      case ExifInterface.ORIENTATION_ROTATE_180: 
       matrix.postRotate(180); 
       break; 
      default: 

     } 
     Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); 
     IV.setImageBitmap(rotatedBitmap); 
    } 


    public void image(){ 
     /* 1) Make a new Uri object (Replace this with a real image on your device) */ 
     Uri imageUri = ImageUri; 

     /* 2) Create a new Intent */ 
     Intent imageEditorIntent = new AdobeImageIntent.Builder(this) 
       .setData(imageUri) 
       .build(); 

     /* 3) Start the Image Editor with request code 1 */ 
     startActivityForResult(imageEditorIntent,EDIT_IMAGE); 

    } 

} 
+1

versuchen Sie diese Gradle Abhängigkeiten, Abhängigkeiten { kompilieren 'com.netflix.rxjava: rxjava-android: 0.20.7' } –

Antwort

0

Laut Oracle-Dokumentation,
ausgelöst, wenn die Java Virtual Machine oder eine ClassLoader-Instanz versucht, die Definition einer Klasse (als Teil eines normalen Methodenaufrufs oder als Teil des Erstellens einer neuen Instanz unter Verwendung des neuen Ausdrucks) und keine Definition der Klasse cou zu laden Ich werde gefunden werden. Die gesuchte Klassendefinition war vorhanden, wenn die aktuell ausgeführte Klasse kompiliert wurde, aber die Definition nicht mehr gefunden werden kann.

So Definition von rx.subjects.PublishSubject nicht gefunden ...

+0

Sie müssen Ihren Code zum besseren Verständnis –

+1

ive Attache den Code gibt es eine Funktion in unten genannt image() wo ich die Bearbeitungsaktivität – TRomesh

+0

@ Tharaka nennen .. Der erzeugte Fehler ist alles wegen der Bibliothek, die Sie verwenden ... stellen Sie einfach sicher, dass Sie alle notwendigen Bibliotheken zusammen mit Ihrem Projekt anhängen, indem Sie ihre kompatible API-Ebene sicherstellen. ... –

0

Blick auf den Paketen es scheint irgendwie Sie nicht in der Lage ist, das rx.subjects.PublishSubject Paket zugreifen oder fehlt. Stellen Sie sicher, dass Sie rxsubjects importieren. *;

+1

wie man es importiert? wie "rxsubjects importieren. *;" Dies??? – TRomesh

+0

versucht, diese gradle Abhängigkeiten, Abhängigkeiten { Kompilierung 'com.netflix.rxjava: rxjava-android: 0.20.7' } –

+1

@ExceptionLover jetzt im einen Fehler wie diese Fehler beim Abruf: Die Ausführung für die Task fehlgeschlagen ': App: transformClassesWithJarMergingForDebug' . > com.android.build.api.transform.TransformException: java.util.zip.ZipException: Doppeleintrag: rx/Observable $ 6.class – TRomesh

4

Dies liegt daran, dass Sie eine Version von Android 4.x verwenden und der MultiDex nicht korrekt implementiert ist. Ich löste dieses Problem nach den nächsten Schritten:

  1. Fügen Sie die folgenden Zeilen in module.gradle

    defaultConfig { multiDexEnabled true }
    compile 'com.android.support:multidex:1.0.1'

  2. Erweitere Klasse Anwendung von MultiDexApplication

Beispiel:

public class Globalapplication extends MultiDexApplication implements IAviaryClientCredentials {...} 
  1. Überschreibung attachBaseContext in der vorherige Klasse

Beispiel:

@Override 
protected void attachBaseContext(Context base) { 
    MultiDex.install(this); 
    super.attachBaseContext(base); 
} 

für weitere Informationen lesen: NoClassDefFoundError with Android Studio on Android 4 https://developer.android.com/studio/build/multidex.html

Verwandte Themen