我正在使用Aviary图片编辑库处理Android应用程序,但遇到了一个问题。在调试器内部运行时,一切都运行良好。但是,当我在手机上运行它时,它会在日志中出现“java.lang.IllegalArugmentException:Unknow URL nulluuid / 6d77d345 .......”错误。我很确定错误与mSessionId变量有关。以下是相关代码:
private void startFeather( Uri uri ) {
Log.d( LOG_TAG, "uri: " + uri );
Intent newIntent = new Intent( this, FeatherActivity.class );
newIntent.setData( uri );
newIntent.putExtra( "API_KEY", API_KEY );
newIntent.putExtra( "output-format", Bitmap.CompressFormat.JPEG.name() );
newIntent.putExtra( "output", Uri.parse(picDir + File.separator + "Final_" + getIntent().getStringExtra("file")));
newIntent.putExtra( "output-quality", 90 );
newIntent.putExtra( "tools-list",
new String[] {
FilterLoaderFactory.Filters.ENHANCE.name(), FilterLoaderFactory.Filters.EFFECTS.name(),
FilterLoaderFactory.Filters.STICKERS.name(), FilterLoaderFactory.Filters.ADJUST.name(),
FilterLoaderFactory.Filters.CROP.name(), FilterLoaderFactory.Filters.BRIGHTNESS.name(),
FilterLoaderFactory.Filters.CONTRAST.name(), FilterLoaderFactory.Filters.SATURATION.name(),
FilterLoaderFactory.Filters.SHARPNESS.name(), FilterLoaderFactory.Filters.DRAWING.name(),
FilterLoaderFactory.Filters.TEXT.name(), FilterLoaderFactory.Filters.MEME.name(),
FilterLoaderFactory.Filters.RED_EYE.name(), FilterLoaderFactory.Filters.WHITEN.name(),
FilterLoaderFactory.Filters.BLEMISH.name(), } );
final DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics( metrics );
final int max_size = Math.max( metrics.widthPixels, metrics.heightPixels );
newIntent.putExtra( "max-image-size", max_size );
newIntent.putExtra( "effect-enable-borders", true );
mSessionId = StringUtils.getSha256( System.currentTimeMillis() + API_KEY );
Log.d( LOG_TAG, "session: " + mSessionId + ", size: " + mSessionId.length() );
newIntent.putExtra( "output-hires-session-id", mSessionId );
startActivityForResult( newIntent, AVIARY_ACTIVITY );
}
我在类中声明了mSessionId变量,但在任何函数之外。
private String mSessionId;
任何想法可能是什么?我被困了几个小时。
编辑:这是对startFeather()的调用:
Uri imagePath = Uri.parse(picDir + File.separator + getIntent().getStringExtra("file"));
startFeather(imagePath);
imagePath的值是:“/ mnt / sdcard / XXXXX / Picts / dd00b97b -eebd-4780-a6c3-993bffdbee37.png”
编辑:这是logcat输出:
05-09 15:28:34.654: D/CLIPBOARD(2965): Hide Clipboard dialog at Starting input: finished by someone else... !
05-09 15:28:35.365: V/XXXX(2965): initPath: dd00b97b-eebd-4780-a6c3-993bffdbee37.png
05-09 15:28:35.375: V/XXXX(2965): fileURI: file:///mnt/sdcard/XXXX/Pictures/dd00b97b-eebd-4780-a6c3-993bffdbee37.png
05-09 15:28:36.166: D/CLIPBOARD(2965): Hide Clipboard dialog at Starting input: finished by someone else... !
05-09 15:28:36.166: W/IInputConnectionWrapper(2965): showStatusIcon on inactive InputConnection
05-09 15:28:42.852: D/XXXX(2965): uri: /mnt/sdcard/XXXX/Pictures/dd00b97b-eebd-4780-a6c3-993bffdbee37.png
05-09 15:28:42.852: D/XXXX(2965): session: 5faf1fb832e59d18e1366f0f458f93a0d5fd3d5ff5a639faae990af4a0e2e7f1, size: 64
05-09 15:28:42.902: D/InputTransport(2965): Input channel constructed: name='407ec7b8 XXXX.app/XXXX.app.PhotoActivity (client)', ashmemFd=49, receivePipeFd=50, sendPipeFd=51
05-09 15:28:42.942: V/Localytics(2965): Opening new session
05-09 15:28:42.972: D/dalvikvm(2965): GC_EXTERNAL_ALLOC freed 134K, 47% free 2984K/5575K, external 3186K/3335K, paused 20ms
05-09 15:28:43.102: D/dalvikvm(2965): GC_EXTERNAL_ALLOC freed 87K, 46% free 3021K/5575K, external 5052K/5631K, paused 20ms
05-09 15:28:43.122: I/dalvikvm(2965): Could not find method com.aviary.android.feather.graphics.AnimatedRotateDrawable.getCallback, referenced from method com.aviary.android.feather.graphics.AnimatedRotateDrawable.invalidateDrawable
05-09 15:28:43.122: W/dalvikvm(2965): VFY: unable to resolve virtual method 4244: Lcom/aviary/android/feather/graphics/AnimatedRotateDrawable;.getCallback ()Landroid/graphics/drawable/Drawable$Callback;
05-09 15:28:43.122: D/dalvikvm(2965): VFY: replacing opcode 0x6e at 0x0006
05-09 15:28:43.122: D/dalvikvm(2965): VFY: dead code 0x0009-000e in Lcom/aviary/android/feather/graphics/AnimatedRotateDrawable;.invalidateDrawable (Landroid/graphics/drawable/Drawable;)V
05-09 15:28:43.122: I/dalvikvm(2965): Could not find method com.aviary.android.feather.graphics.AnimatedRotateDrawable.getCallback, referenced from method com.aviary.android.feather.graphics.AnimatedRotateDrawable.scheduleDrawable
05-09 15:28:43.122: W/dalvikvm(2965): VFY: unable to resolve virtual method 4244: Lcom/aviary/android/feather/graphics/AnimatedRotateDrawable;.getCallback ()Landroid/graphics/drawable/Drawable$Callback;
05-09 15:28:43.122: D/dalvikvm(2965): VFY: replacing opcode 0x6e at 0x0006
05-09 15:28:43.122: D/dalvikvm(2965): VFY: dead code 0x0009-000e in Lcom/aviary/android/feather/graphics/AnimatedRotateDrawable;.scheduleDrawable (Landroid/graphics/drawable/Drawable;Ljava/lang/Runnable;J)V
05-09 15:28:43.122: I/dalvikvm(2965): Could not find method com.aviary.android.feather.graphics.AnimatedRotateDrawable.getCallback, referenced from method com.aviary.android.feather.graphics.AnimatedRotateDrawable.unscheduleDrawable
05-09 15:28:43.122: W/dalvikvm(2965): VFY: unable to resolve virtual method 4244: Lcom/aviary/android/feather/graphics/AnimatedRotateDrawable;.getCallback ()Landroid/graphics/drawable/Drawable$Callback;
05-09 15:28:43.122: D/dalvikvm(2965): VFY: replacing opcode 0x6e at 0x0006
05-09 15:28:43.122: D/dalvikvm(2965): VFY: dead code 0x0009-000e in Lcom/aviary/android/feather/graphics/AnimatedRotateDrawable;.unscheduleDrawable (Landroid/graphics/drawable/Drawable;Ljava/lang/Runnable;)V
05-09 15:28:43.122: I/dalvikvm(2965): Could not find method android.app.ActivityManager.getLargeMemoryClass, referenced from method com.aviary.android.feather.Constants.initContext
05-09 15:28:43.122: W/dalvikvm(2965): VFY: unable to resolve virtual method 36: Landroid/app/ActivityManager;.getLargeMemoryClass ()I
05-09 15:28:43.132: D/dalvikvm(2965): VFY: replacing opcode 0x6e at 0x0024
05-09 15:28:43.132: D/dalvikvm(2965): VFY: dead code 0x0027-002e in Lcom/aviary/android/feather/Constants;.initContext (Landroid/content/Context;)V
05-09 15:28:43.132: D/dalvikvm(2965): VFY: dead code 0x0052-0053 in Lcom/aviary/android/feather/Constants;.initContext (Landroid/content/Context;)V
05-09 15:28:43.132: I/feather(2965): screen size: 480x800
05-09 15:28:43.132: D/dalvikvm(2965): No JNI_OnLoad found in /system/lib/libcutils.so 0x4051e4e8, skipping init
05-09 15:28:43.132: D/dalvikvm(2965): Trying to load lib /data/data/XXXX.app/lib/libstlport_shared.so 0x4051e4e8
05-09 15:28:43.132: D/dalvikvm(2965): Added shared lib /data/data/XXXX.app/lib/libstlport_shared.so 0x4051e4e8
05-09 15:28:43.132: D/dalvikvm(2965): No JNI_OnLoad found in /data/data/XXXX.app/lib/libstlport_shared.so 0x4051e4e8, skipping init
05-09 15:28:43.132: D/dalvikvm(2965): Trying to load lib /data/data/XXXX.app/lib/libfeathernative.so 0x4051e4e8
05-09 15:28:43.132: D/dalvikvm(2965): Added shared lib /data/data/XXXX.app/lib/libfeathernative.so 0x4051e4e8
05-09 15:28:43.142: E/filter-native(2965): cpu: armv7? 1
05-09 15:28:43.142: E/filter-native(2965): cpu: fpu? 1
05-09 15:28:43.142: E/filter-native(2965): cpu: neon? 1
05-09 15:28:43.202: D/dalvikvm(2965): GC_CONCURRENT freed 143K, 46% free 3089K/5639K, external 5403K/6381K, paused 2ms+2ms
05-09 15:28:43.202: E/feather(2965): [FeatherActivity] , MAX MEMORY, 64
05-09 15:28:43.202: D/InputTransport(2965): Input channel constructed: name='40801d90 XXXX.app/com.aviary.android.feather.FeatherActivity (client)', ashmemFd=64, receivePipeFd=65, sendPipeFd=66
05-09 15:28:43.243: D/dalvikvm(2965): GC_EXTERNAL_ALLOC freed 67K, 47% free 3112K/5767K, external 5395K/6381K, paused 26ms
05-09 15:28:43.793: I/image(2965): setImageBitmap: android.graphics.Bitmap@40635790
05-09 15:28:43.793: E/feather(2965): [FeatherActivity] , original.size: 2448x3264
05-09 15:28:43.793: E/feather(2965): [FeatherActivity] , final.size: 600x800
05-09 15:28:43.793: W/dalvikvm(2965): threadid=14: thread exiting with uncaught exception (group=0x4001e578)
05-09 15:28:43.803: E/AndroidRuntime(2965): FATAL EXCEPTION: Service[hiresService]
05-09 15:28:43.803: E/AndroidRuntime(2965): java.lang.IllegalArgumentException: Unknown URL nulluuid/5faf1fb832e59d18e1366f0f458f93a0d5fd3d5ff5a639faae990af4a0e2e7f1
05-09 15:28:43.803: E/AndroidRuntime(2965): at android.content.ContentResolver.insert(ContentResolver.java:600)
05-09 15:28:43.803: E/AndroidRuntime(2965): at com.aviary.android.feather.library.services.HiResService$1.run(HiResService.java:120)
05-09 15:28:43.803: E/AndroidRuntime(2965): at android.os.Handler.handleCallback(Handler.java:587)
05-09 15:28:43.803: E/AndroidRuntime(2965): at android.os.Handler.dispatchMessage(Handler.java:92)
05-09 15:28:43.803: E/AndroidRuntime(2965): at android.os.Looper.loop(Looper.java:130)
05-09 15:28:43.803: E/AndroidRuntime(2965): at android.os.HandlerThread.run(HandlerThread.java:60)
05-09 15:28:44.013: D/InputTransport(2965): Input channel constructed: name='408ab4f0 Toast (client)', ashmemFd=75, receivePipeFd=76, sendPipeFd=77
05-09 15:28:44.123: D/InputTransport(2965): Input channel destroyed: name='40801d90 XXXX.app/com.aviary.android.feather.FeatherActivity (client)', ashmemFd=64, receivePipeFd=65, sendPipeFd=66
05-09 15:28:44.123: D/InputTransport(2965): Input channel destroyed: name='407ec7b8 XXXX.app/XXXX.app.PhotoActivity (client)', ashmemFd=49, receivePipeFd=50, sendPipeFd=51
05-09 15:28:45.995: D/InputTransport(2965): Input channel destroyed: name='408ab4f0 Toast (client)', ashmemFd=75, receivePipeFd=76, sendPipeFd=77
通过实验,我发现问题肯定在于mSessionId = StringUtils.getSha256(System.currentTimeMillis()+ API_KEY);线。如果我将其注释掉(禁用高分辨率处理),它可以正常工作。
答案 0 :(得分:4)
供将来参考...如果其他人有此错误,您必须在清单文件中添加:
<!-- Required for the hi-res image processing -->
<!-- authorities can have the value you prefer -->
<provider
android:name="com.aviary.android.feather.library.providers.FeatherContentProvider"
android:exported="false"
android:authorities="com.aviary.launcher.HiResProvider">
</provider>
答案 1 :(得分:2)
我也遇到了同样的问题。我的解决方案是增加eclipse的堆大小和perm的内存。看来,当它没有足够的内存时,eclipse ADT将无法正确构建apk。当android项目包含大型jar lib(如鸟舍)时会发生这种情况。
要增加eclipse的内存,请编辑eclipse.ini并更改以下值: -XX:MaxPermSize参数=512米 -Xms512m -Xmx1024m
希望得到这个帮助。
答案 2 :(得分:0)
newIntent.putExtra( "output", Uri.parse( "file://" + mOutputFile.getAbsolutePath() ) );
我想,我们需要更多代码来回答你的问题。 但我注意到的一件事是你的Uri没有以“file://”前缀开头,如文档中所示。
无论如何,我认为问题与Uri有关,因为在contentprovider中插入Url时,错误是抱怨IllegalArgumentException。
Doublecheck,您的Uri存在于设备上,并以“file://”开头,并将结果发布给我们
答案 3 :(得分:0)
要启用“高分辨率图像编辑”,需要执行其他步骤,请参阅offcial documentation
中的 10高分辨率图像编辑一节