oschina github源码V2.7.1源码用Android Studio打开成功,并编译通过

【1】本地andrioid studio环境介绍
gradle:2.3.1
https\://services.gradle.org/distributions/gradle-3.3-all.zip
【2】下载oschina-android-app-v2.7.1.zip
这里在百度网盘给备份下 http://pan.baidu.com/s/1o8RsXDo

【3】根据本地AS环境修改下载的源码

【3.1】解压后工程根目录下的build.gradle文件修改如何

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        //classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.3.0'
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://dl.bintray.com/oschinaapp/maven/'
        }
    }
}

ext {
    compileSdkVersion = 24
    buildToolsVersion = "25.0.0"
    applicationId = "net.oschina.app"
    minSdkVersion = 19
    targetSdkVersion = 25
    versionCode = 271
    versionName = "v2.7.1(1612211352)"
    supportVersion = '25.1.0'
}
修改了四行内容
classpath 'com.android.tools.build:gradle:2.3.1'
        //classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.3.0'
buildToolsVersion = "25.0.0"
targetSdkVersion = 25
【3.2】修改android-app-v2.7.1\gradle\wrapper\gradle-wrapper.properties 最后一行的版本为3.3

#Tue Dec 20 13:45:41 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
【3.3】注释掉 android-app-v2.7.1\app\build.gradle中的buildTypes部分,这里是keystore
apply plugin: 'com.android.application'
apply from: '../config/properties-util.gradle'

android {

    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId rootProject.ext.applicationId
        minSdkVersion rootProject.ext.minSdkVersion
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    // rename the apk with the version name
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.outputFile = new File(
                    output.outputFile.parent + "/${variant.buildType.name}",
                    "osc-android-${variant.versionName}-${variant.productFlavors[0].name}-${variant.buildType.name}.apk".toLowerCase())
        }
    }

    //signing files settings
    signingConfigs {
        if (propertyHaveSigningConfigs) {
            debug {
                storeFile file(propertyStoreFileStr)
                storePassword propertyStorePwdStr
                keyAlias propertyKeyAliasStr
                keyPassword propertyKeyPwdStr
            }

            release {
                storeFile file(propertyStoreFileStr)
                storePassword propertyStorePwdStr
                keyAlias propertyKeyAliasStr
                keyPassword propertyKeyPwdStr
            }
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }

    // 移除lint检查的error
    lintOptions {
        abortOnError false
    }
/*
    //build type setting
    buildTypes {

        debug {
            zipAlignEnabled false
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            if (propertyHaveSigningConfigs)
                signingConfig signingConfigs.debug
        }

        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            if (propertyHaveSigningConfigs)
                signingConfig signingConfigs.release
        }
    }
*/
    //product flavors
    productFlavors {
        oschina {
            manifestPlaceholders = [UMENG_CHANNEL: "oschina"]
        }

        wandoujia {
            manifestPlaceholders = [UMENG_CHANNEL: "wandoujia"]
        }

        xiaomi {
            manifestPlaceholders = [UMENG_CHANNEL: "xiaomi"]
        }
    }
}

repositories {
    flatDir {
        dirs 'libs'
    }
    if (propertyHaveDebugCompile) {
        maven {
            url propertyDebugCompileUrl
        }
    }
}

dependencies {
    compile "com.android.support:support-v4:$rootProject.ext.supportVersion"
    compile "com.android.support:appcompat-v7:$rootProject.ext.supportVersion"
    compile "com.android.support:design:$rootProject.ext.supportVersion"
    compile "com.android.support:recyclerview-v7:$rootProject.ext.supportVersion"
    compile "com.android.support:cardview-v7:$rootProject.ext.supportVersion"

    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':open')
    compile 'com.github.chrisbanes.photoview:library:1.2.4'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'org.kymjs.kjframe:kjframe:2.6'
    compile 'com.google.zxing:core:3.3.0'
    compile 'com.joanzapata.android:android-iconify:1.0.9'
    compile 'com.makeramen:roundedimageview:2.1.1'
    compile 'pub.devrel:easypermissions:0.1.7'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'de.hdodenhof:circleimageview:2.0.0'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'net.qiujuer.genius:graphics:2.0.0-beta8'
    compile 'net.qiujuer.genius:res:2.0.0-beta8'
    compile 'net.qiujuer.genius:ui:2.0.0-beta8'
    compile 'com.umeng.analytics:analytics:latest.integration'
    compile 'net.oschina.common:common:0.1.0'

    if (propertyHaveDebugCompile) {
        compile propertyDebugCompile
    }

    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.android.application'
//apply plugin: 'com.getkeepsafe.dexcount'
并且将最后一行dexcount给注释掉,添加上面一行apply plugin:'com.android.application'
至此就可以编译成功了








评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值