taratara10 / Topicker

0 stars 0 forks source link

build.gradleのバージョン管理(ktsを添えて) #47

Closed taratara10 closed 1 year ago

taratara10 commented 1 year ago

18 の続き

ライブラリが直置きなので、version管理したい

ついでにkts化もしたい

taratara10 commented 1 year ago

https://qiita.com/mangano-ito/items/0537d70701e1e85223e7

やる

taratara10 commented 1 year ago

Caused by: java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library [androidx.appcompat:appcompat-resources:1.5.1]

Caused by: java.lang.RuntimeException: Manifest merger failed : uses-sdk:minSdkVersion 1 cannot be smaller than version 14 declared in library

https://stackoverflow.com/questions/30204426/manifest-merger-failed-uses-sdkminsdkversion-1-cannot-be-smaller-than-version

taratara10 commented 1 year ago

困った時の./gradlew assemble_mockDebug --stacktrace

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     Your current JDK is located in  C:\Program Files\Java\jdk1.8.0_311\jre
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

javaが11なのか

> ./gradlew -version

------------------------------------------------------------
Gradle 7.3.3
------------------------------------------------------------

Build time:   2021-12-22 12:37:54 UTC
Revision:     6f556c80f945dc54b50e0be633da6c62dbe8dc71

Kotlin:       1.5.31
Groovy:       3.0.9
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          1.8.0_311 (Oracle Corporation 25.311-b11)
OS:           Windows 10 10.0 amd64

https://android.benigumo.com/20211202/androidstudio-java-jdk/

taratara10 commented 1 year ago
plugins {
    id("com.android.application")
    id("org.jetbrains.kotlin.android")
    id("kotlin-kapt")
    id("dagger.hilt.android.plugin")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
}

android {
    compileSdk = 33

    defaultConfig {
        applicationId = "com.kabos.topicker"
        minSdk = 26
        targetSdk = 33
        versionCode = 1
        versionName = "1.0.0"

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary = true
        }
    }

    buildTypes {
        release {
            isMinifyEnabled = false
            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
        }
    }

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    buildFeatures {
        compose = true
    }

    composeOptions {
        kotlinCompilerExtensionVersion = "1.3.0"
    }

    packagingOptions {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
        }
    }

//    flavorDimensions.add("appType")
//    productFlavors {
//        create("_mock") {
//            dimension = "appType"
//            applicationIdSuffix = ".mock"
//            versionNameSuffix = "-mock"
//        }
//        create("_dev") {
//            dimension = "appType"
//            applicationIdSuffix = ".dev"
//            versionNameSuffix = "-dev"
//        }
//        create("_prd") {
//            dimension = "appType"
//        }
//    }
}

dependencies {
    implementation(project(":core:model"))
    implementation(project(":core:data"))
    implementation(project(":core:domain"))
    implementation(project(":core:datastore"))

    implementation("androidx.core:core-ktx:1.8.0")
    implementation("androidx.compose.ui:ui:1.2.1")
    implementation("androidx.compose.material:material:1.3.0-rc01")
    implementation("androidx.compose.ui:ui-tooling-preview:1.2.1")
    implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1")
    implementation("androidx.activity:activity-compose:1.6.0")
    testImplementation("junit:junit:4.13.2")
    androidTestImplementation("androidx.test.ext:junit:1.1.3")
    androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
    androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.2.1")
    debugImplementation("androidx.compose.ui:ui-tooling:1.2.1")
    debugImplementation("androidx.compose.ui:ui-test-manifest:1.2.1")

    implementation("com.google.accompanist:accompanist-pager:0.26.1-alpha")
    implementation("com.jakewharton.timber:timber:4.7.1")

    implementation("com.google.dagger:hilt-android:2.42")
    kapt("com.google.dagger:hilt-android-compiler:2.42")

    implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.1")
    implementation("androidx.compose.runtime:runtime-livedata:1.2.1")

    implementation("com.airbnb.android:lottie-compose:5.2.0")

    implementation(platform("com.google.firebase:firebase-bom:30.3.1"))
    implementation("com.google.firebase:firebase-firestore-ktx:24.3.1")

    // dataStore
    implementation("androidx.datastore:datastore-preferences:1.0.0")

    implementation("androidx.navigation:navigation-compose:2.5.2")
    implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
}
plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
}

android {
    namespace 'com.kabos.data'
    compileSdk 32

//    def DIMENSION_DEFAULT = "default"
//    flavorDimensions DIMENSION_DEFAULT
//    productFlavors {
//        mock {
//            dimension DIMENSION_DEFAULT
//        }
//        dev {
//            dimension DIMENSION_DEFAULT
//        }
//        prd {
//            dimension DIMENSION_DEFAULT
//        }
//    }
//
//    sourceSets {
//        mock {
//            java.srcDirs("src/mock/java")
//        }
//        dev {
//            java.srcDirs("src/main/java")
//        }
//        prd {
//            java.srcDirs("src/main/java")
//        }
//    }
}

dependencies {
    implementation project(":core:model")
    implementation project(":core:domain")
    implementation project(":core:datastore")

    testImplementation 'junit:junit:4.13.2'

    implementation platform('com.google.firebase:firebase-bom:30.3.1')
    implementation 'com.google.firebase:firebase-firestore-ktx:24.3.1'

    implementation 'com.jakewharton.timber:timber:4.7.1'

    // firebaseでawait()するやつ
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.1"

    // dataStore
    implementation("androidx.datastore:datastore-preferences-core:1.0.0")
}
taratara10 commented 1 year ago
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

君かぁ!!!

taratara10 commented 1 year ago

ん????

Execution failed for task ':app:process_devDebugGoogleServices'. > No matching client found for package name

もしかして、suffix追加したらgoogle-service.jsonにidがないだけの話????

taratara10 commented 1 year ago

だああああああああああああああああ 解決 何がJAVA11やねん、くそq

taratara10 commented 1 year ago

これnameSpace

46 でやる

taratara10 commented 1 year ago

https://zenn.dev/nagaoooon/articles/edef0104bb764b

まぁNowInAndroidほど共通化しなくてもいいか

taratara10 commented 1 year ago

https://docs.gradle.org/7.3.3/userguide/platforms.html

versionCatalog革新的すぎる~~~ 顧客が求めていたもの

taratara10 commented 1 year ago

めっちゃ時間かかったけど、implementationの情報マスキングに成功 これはいいものだ、、、

taratara10 commented 1 year ago

あとはpluginとかを整理する

taratara10 commented 1 year ago

ついでにktlintもallProjectに適応するか https://qiita.com/irgaly/items/45f84311f0c17a785644

taratara10 commented 1 year ago

あ~~~~ top level のbuild.gradle classpathとかplugin何かわかってなかったけど、appのgradleでpluginしてるやつか!

:app

plugins {
    kotlin("android")
    id("com.android.application")
    id("kotlin-kapt")
    id("dagger.hilt.android.plugin")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
}

:root

buildscript {

    dependencies {
        classpath (libs.buildscript.hilt)
        classpath ("com.google.gms:google-services:4.3.14")
        classpath ("com.google.firebase:firebase-crashlytics-gradle:2.9.2")
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
    id("com.android.application") version "7.2.1" apply false
    id("com.android.library") version "7.2.1" apply false
    id("org.jetbrains.kotlin.android") version "1.7.10" apply false
}