同步操作将从 志威/android-app 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
本项目为
fork
开源中国的android
版本4.1.7
最新开源代码,并使用Android Studio 3.2.1
版本,更新gradle
配置为当前最新态4.10
(在项目下的gradle
目录内,wrapper
文件夹的gradle-wrapper.properties
内配置),编译运行成功。希望有助于大家研究学习。原项目地址http://www.oschina.net/p/oschina-android-app
clone
官方的源码之后,发现好多依赖库,以及配置都比较老旧,而且在新版的AndroidStudio
上是无法运行。所以尝试解决问题,编译并运行OK,改变点记录如下:
修改编译版本
//改为28编译
ext {
compileSdkVersion = 28
buildToolsVersion = "28.0.3"
applicationId = "net.oschina.app"
minSdkVersion = 19
targetSdkVersion = 28
versionCode = 417
versionName = "v4.1.7 (1806190800)"
supportVersion = '28.0.0'
}
修改gradle
以及dexcount
版本
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//更新gradle版本为3.2.1,以及dexcount版本为0.6.2
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
}
}
allprojects {
repositories {
//添加阿里云的源,下载快速
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
jcenter()
mavenCentral()
google()
maven { url 'https://dl.bintray.com/oschinaapp/maven/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://jitpack.io' }
}
}
解决Dimensions
错误
//在app目录下的buidle.gradle文件内,添加如下,在android{}闭包内
flavorDimensions "versions"
解决gradle版本升级引起的错误
//在android{}闭包下,修改生成apk的命名配置
// rename the apk with the version name
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "osc-android-${variant.versionName}-${variant.productFlavors[0].name}.apk".toLowerCase()
}
}
解决com.android.tools.r8.utils.AbortException: Error: Static interface methods are only supported starting with Android N
//android{}闭包内添加
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
theme.xml
错误,引起编译错误
<!--191行,theme配置错误,少了@符号,这里补上 -->
<style name="Theme.App.ActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<!-- Support library compatibility -->
<item name="elevation">0dp</item>
</style>
AndroidManifest.xml
中有一条重复的meta-data
百度的数据配置,删除。
配置BuildConfig
应用到的key
,在local.properties
文件中
## 替换为开发者在OSChina上申请的openapi的key
AES_KEY = 1234567891234567
AES_IV = 9876543217894561
VIOLET_PASSCODE = 123
更新dependencies
,使用androidx
支持库
//更新support库为androidx,更新butterknife为9.0版本
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible,GradleDependency
implementation 'androidx.legacy:legacy-support-v4:1.0.0-alpha1'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0-rc01'
implementation project(':open')
if (propertyHaveDebugCompile) {
implementation propertyDebugCompile
}
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-alpha3', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.github.chrisbanes.photoview:library:1.2.4'
implementation 'com.loopj.android:android-async-http:1.4.9'
//noinspection GradleDependency
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.joanzapata.android:android-iconify:1.0.9'
implementation 'com.makeramen:roundedimageview:2.1.1'
implementation 'pub.devrel:easypermissions:0.3.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
//noinspection GradleDependency
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.upyun:upyun-android-sdk:2.0.5'
//noinspection GradleDependency
// implementation 'com.umeng.analytics:analytics:latest.integration'
//noinspection GradleDependency
implementation 'com.baidu.mobstat:mtj-sdk:latest.integration'
//noinspection GradleDependency
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'net.oschina.common:common:0.2.1'
implementation 'com.belerweb:pinyin4j:2.5.1'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.6.0'
implementation 'com.hyman:flowlayout-lib:1.1.2'
implementation('com.github.mcxtzhang:SwipeDelMenuLayout:V1.2.5') {
exclude group: 'com.android.support:appcompat-v7', module: 'support-v4'
}
testImplementation 'junit:junit:4.12'
}
更新butterknife
并修改代码中的@Bind
为@BindView
,其中有一个使用了@BindViews
以及低版本有个ButterKnife.unbind(this);
这个函数,可以去掉。
修改之后,基本便可以正常运行,如果不配置开发者申请的key,则会拉取不到内容信息。在此,感谢开源中国,给大家一个学习交流的平台!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。