hi, 大家好,我是爱吃香蕉的猴子,移植8.0的Camera2到AS4.1.1;
新建工程Camera2O
repositories {
maven {
url 'https://maven.aliyun.com/repository/google' }
maven {
url 'https://maven.aliyun.com/repository/jcenter' }
maven {
url 'http://maven.aliyun.com/nexus/content/groups/public' }
google()
}
allprojects {
repositories {
.....
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs.add('-Xbootclasspath/p:libs/framework.jar')
}
}
}
配置build.gradle(app) android {配置}
sourceSets {
main {
res.srcDirs = [
'../Camera2/res',
]
java.srcDirs = [
'src/main/java',
'../Camera2/src',
'../Camera2/src_pd',
'../Camera2/src_pd_gcam',
]
manifest.srcFile '../Camera2/AndroidManifest.xml'
}
}
根据Android.mk配置dependencies
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v13
LOCAL_STATIC_JAVA_LIBRARIES += android-ex-camera2-portability
LOCAL_STATIC_JAVA_LIBRARIES += xmp_toolkit
LOCAL_STATIC_JAVA_LIBRARIES += glide
LOCAL_STATIC_JAVA_LIBRARIES += guava
LOCAL_STATIC_JAVA_LIBRARIES += jsr305
增加Module
implementation project(path: ':glidelib')
implementation project(path: ':xmplib')
implementation project(path: ':guavalib')
implementation project(path: ':jsrlib')
implementation project(path: ':portabilitylib')
//noinspection GradleCompatible
implementation 'com.android.support:support-v13:26.0.0'
compileOnly files('../libs/framework.jar')
//implementation 'com.android.support:support-v4:27.0.0-alpha1'
implementation 'com.android.support:appcompat-v7:26.0.0'
上面是自己已经配置好之后的,实际操作时要一个modlue一个module的创建, 现在将Camera2源码的项目copy到工程的根目录,然后sync一下;
新建一个Module glidelib
配置build.gradle(glidelib)
sourceSets {
main {
java.srcDirs = [
'src/main/java',
'../glide/src',
'../glide/library',
'../glide/third_party',
]
manifest.srcFile '../glide/library/src/main/AndroidManifest.xml'
}
}
其他的几个Module也按照这个流程进行;我这里就不一个一个介绍了。
配置完之后,再进行编译 看看有什么错误,根据错误进行修正,根据我经验大概都是一些xml文件,容易纠正;
Code的搬运工V1.0