Win10操作系统
Android Studio 2022版
Gradle插件和Gradle版本:
SDK版本:
依赖添加情况:
由于该项目原本是基于Eclipse来进行开发,所以我们需要使用AS的import project来使用gradle将该项目重新构建。
主要问题为:这报错信息中的Add google Maven repository and sync project,看来可能Project的build.gradle少了google()* 然后这个问题就解决了~
点击AS中的绿色小锤子make project
vmoptions
文件下去添加-Dfile.encoding=UTF-8
语句:android:exported="true"
private void showNotification(int tickerId, String content) {PendingIntent pendingIntent;if (tickerId != R.string.ticker_success) {pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,NotesPreferenceActivity.class), 0);} else {pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,NotesListActivity.class), 0);}Notification.Builder builder = new Notification.Builder(mContext).setAutoCancel(true).setContentTitle(mContext.getString(R.string.app_name)).setContentText(content).setContentIntent(pendingIntent).setWhen(System.currentTimeMillis()).setOngoing(true);Notification notification=builder.getNotification();mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);}
这个难题我找了很多资料也没有解决,最后是靠自己的顿悟,想到既然类重复的原因是各种jar之间的冲突,那我只需要保留我最需要的包,把其它有冲突的包都忽略不就行了吗?
顺者网上相关问题的无效版,我了解到大概重要的jar包是哪些:
我把和这3个jar包有冲突的包都exclude了:
解决项目搭建的问题:
项目搭建参考博客1
项目搭建参考博客2
解决Could not find com.android.tools.build:gradle:(各种版本)
Could not find com.android.tools.build:gradle:(各种版本)
解决项目运行的问题:
解决命令行乱码问题
解决项目依赖包缺失的问题
解决安卓组件不允许进行跨进程调用的问题
android:exported=“true”
android:exported="true"是什么
android:exported 其实并不是Android12的新属性在前面的版本也可以看见它。它是Android中的四大组件 Activity,Service,Provider,Receiver 四大组件中都会有的一个属性。
作用是什么
在Activity中该属性用来标示:当前Activity是否可以被另一个Application的组件启动:true允许被启动;false不允许被启动。
如果它写在service中并且为false则表示则该服务不能够跨进程使用。
所以总体来说它的主要作用是:是否支持其它应用调用当前组件。
以前在我们需要的时候需要自己手动写,但是在Android12中他会默认添加并且默认为true。
把里面提到的所有的安卓的组件中都给加上了android:exported=“true”
解决Cannot resolve method ‘setLatestEventInfo’ in 'Notification’的问题
用重写的函数替代原本的函数。