学习笔记之——android配置清单和gradle构建文件

本博文讲本人学习android配置清单和gradle构建文件做的记录给出。由于是直接写在对应的文件的注释上的,所以直接给出代码~

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.androidopencvtest">

<!--    声明所需要的用户权限-->
    <uses-permission android:name="android.permission.CAMERA" />

<!--    定义一系列的app属性,如app的名字,图标-->
<!--    可通过巧妙使用string来统一管理一系列的属性名字-->
    <application
        android:allowBackup="true"
        android:icon="@mipmap/icon1"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/icon1"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

<!--        下面定义一些列的activity-->
        <activity android:name=".ICDC_Map_Activity"></activity>
        <activity android:name=".Camera_Activity" />
        <activity android:name=".ROI_2LED" />
        <activity android:name=".Main2Activity" />


        <activity android:name=".MainActivity">
            <!-- 通过intent-filter标签指定启动activity -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


    </application>

</manifest>

项目的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
//指定依赖库和依赖项

buildscript {
//    用于指定Gradle本身使用的远程创库和依赖项
    repositories {
        //用于查找依赖项的远程库
        google()
        jcenter()
        
    }
    dependencies {
        //包含了用于Gradle的Android插件
        classpath 'com.android.tools.build:gradle:3.6.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    //指定项目中所有模块会使用的远程创库和依赖项
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    //用于删除项目中build文件夹下的内容
    delete rootProject.buildDir
}

app的build.gradle

//用于为相应的模块配置构建设置项
apply plugin: 'com.android.application' //将Gradle的android插件应用到构建中,这使能够通过android代码块指定Android特定的构建项

android {//确保在下载新的SDK时,更新这些值
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {//指定了一些默认设置
        applicationId "com.example.androidopencvtest"//提供唯一的包名,用于标识构建的APK以进行发布和分发
        minSdkVersion 16 //设置应用要兼容的最小Android平台。如果系统的API级别低于此值,android框架将会组织用于安装应用
        targetSdkVersion 29   //指定进行开发和测试的Android平台版本。(目标SDK版本)
        versionCode 1   //将当前应用版本定义为一个整数,这个整数会随着发布的每一个版本迭代增加而增加
        versionName "1.0"   //指定将显示给用户的公开版本标识符

        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
                abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a'
                arguments "-DANDROID_STL=c++_shared"
                targets "opencv_jni_shared"
            }
        }


        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"   //指定要使用的测试运行程序。
    }

    buildTypes {  //用于定义不同的构建类型
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['src/main/jniLibs']
        }
    }


}

dependencies {//指定构建应用时所需要的所有依赖项

    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation project(path: ':opencv430')

}

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值