Fork me on GitHub

重构智慧社区遇到的问题

transformNativeLibsWithStripDebugSymbolForDebug
1
2
Error:Execution failed for task ':zhhxProperty:transformNativeLibsWithStripDebugSymbolForDebug'.
> java.lang.NullPointerException (no error message)
解决方案:

compileSdkVersion 19改成compileSdkVersion 27,即升级所有modulecompileSdkVersion

程序包org.apache.http不存在
解决方案:

build.gradle中,在buildToolsVersiondefaultConfig之间添加如下代码

1
useLibrary 'org.apache.http.legacy'

FloatMath不存在

找不到符号FloatMath
符号: 方法 floor(float)
位置: 类 FloatMath

解决方案:

FloatMath.floor()改成Math.floor()

setLatestEventInfo

Error:(403, 25) 错误: 找不到符号
符号: 方法 setLatestEventInfo(Context,String,String,PendingIntent)
位置: 类型为Notification的变量 notification

解决方案:

notification.setLatestEventInfo(context, title, message, pi);
改成showNotification(pi,title,message);

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
private void showNotification(PendingIntent contentIntent, String contentTitle, String contentText) {
//2、发布到通知栏,让监听者能点击
//获取NotificationManager实例
NotificationManager notifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//实例化NotificationCompat.Builde并设置相关属性
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setContentIntent(contentIntent)
.setDefaults(Notification.DEFAULT_ALL)
//设置小图标
.setSmallIcon(R.mipmap.ic_launcher)
//设置通知标题
.setContentTitle(TextUtils.isEmpty(contentTitle) ? getResources().getString(R.string.app_name) : contentTitle)
.setAutoCancel(true)
//设置通知内容
.setContentText(contentText);
//通过builder.build()方法生成Notification对象,并发送通知,id=1
notifyManager.notify(1, builder.build());
}

找不到Frganment的getContext()方法。

Error:(197, 28) 错误: 找不到符号
符号: 方法 getContext()
位置: 类 ComplaintClosedFragment

解决方法:

改用getActivity()方法。

找不到ViewPager的addOnPageChangeListener()方法。

Error:(428, 23) 错误: 找不到符号
符号: 方法 addOnPageChangeListener(ComplaintFragment.TabOnPageChangeListener)
位置: 类型为ViewPager的变量 mViewPager

解决方法:

改用setOnPageChangeListener()方法。

javaPreCompileDebug报错
1
2
3
4
5
Error:Execution failed for task ':zhhxProperty:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- realm-android-0.87.4.jar (realm-android-0.87.4.jar)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
解决方案:

在defaultconfig添加

1
2
3
4
5
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}

android.dexOptions.incremental deprecated
1
Warning:The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.
解决方案:

删除如下代码的incremental属性

1
2
3
4
dexOptions {
incremental true
javaMaxHeapSize "4g"
}

transformDexArchiveWithExternalLibsDexMergerForDebug
1
2
Error:Execution failed for task ':zhhxProperty:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
解决方案:

通过aar引用了某工程,又通过module引用了,删掉module引用即可。

TODO

1、图片框架改造;
http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html