gpt4 book ai didi

android - Jetpack 撰写新源不工作

转载 作者:行者123 更新时间:2023-12-04 15:41:01 25 4
gpt4 key购买 nike

我已经尝试使用旧的预构建源代码编写 Jetpack。但是最近我下载了一个新源,但它对我不起作用。这是我尝试过的。

I have added source in Project/androidx_prebuilts/out/ui/build/support_repo/androidx

在 androidx 目录下,我有 composeui源目录

Module level gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

repositories {
maven { url "$androidx_home/out/ui/build/support_repo/" }
google()
jcenter()
}

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.compose.app"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
// typeuseIR = true
freeCompilerArgs += "-P"
freeCompilerArgs +=
"plugin:androidx.compose.plugins.kotlin:syntax=FCS"
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}

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

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.41"
implementation "androidx.appcompat:appcompat:1.0.2"
implementation "androidx.core:core-ktx:1.0.2"

implementation "androidx.compose:compose-runtime:1.0.0-alpha01"
implementation "androidx.ui:ui-animation:1.0.0-alpha01"
implementation "androidx.ui:ui-animation-core:1.0.0-alpha01"
implementation "androidx.ui:ui-android-view:1.0.0-alpha01"
implementation "androidx.ui:ui-android-view-non-ir:1.0.0-alpha01"
implementation "androidx.ui:ui-android-text:1.0.0-alpha01"
implementation "androidx.ui:ui-core:1.0.0-alpha01"
implementation "androidx.ui:ui-framework:1.0.0-alpha01"
implementation "androidx.ui:ui-layout:1.0.0-alpha01"
implementation "androidx.ui:ui-material:1.0.0-alpha01"
implementation "androidx.ui:ui-platform:1.0.0-alpha01"
implementation "androidx.ui:ui-text:1.0.0-alpha01"


testImplementation "junit:junit:4.12"
androidTestImplementation "androidx.test:runner:1.1.1"
androidTestImplementation "androidx.test.espresso:espresso-core:3.1.1"
}

Application level gradle

buildscript {
ext.kotlin_version = "1.3.41"
ext.androidx_home = project.properties["androidx.home"] ?: "$projectDir/androidx_prebuilts"
repositories {
maven { url "$androidx_home/out/ui/build/support_repo/" }
maven {
url "http://dl.bintray.com/kotlin/kotlin-eap"
}

mavenLocal()
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0-alpha09'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

apply plugin: 'idea'

idea.module {
excludeDirs += file('$projectDir/androidx_prebuilts')
}

allprojects {
repositories {

maven {
url "https://dl.bintray.com/kotlin/kotlin-dev/"
}
maven { url "$androidx_home/out/ui/build/support_repo/" }

mavenLocal()
google()
jcenter()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

Error I'm getting while building the project

  * What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find androidx.compose:compose-runtime:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-animation:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-animation-core:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-android-view:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-android-view-non-ir:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-android-text:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-core:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-framework:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-layout:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-material:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-platform:1.0.0-alpha01.
Required by:
project :app
> Could not find androidx.ui:ui-text:1.0.0-alpha01.
Required by:
project :app

最佳答案

首先,请参阅此文档:googlesource

“本节介绍如何设置本地工作环境以构建 Android 源文件。您必须使用 Linux 或 macOS;目前不支持在 Windows 下构建。” — 安卓文档

Step 1:

首先,我们需要从(如果没有安装)安装 Repo https://source.android.com/setup/build/downloading

然后在你的命令行中点击下面的命令

mkdir bin 
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

现在检查 repo 状态

Step 2:

创建一个目录让我们说“AndroidCompose”

mkdir ~/AndroidCompose
cd ~/AndroidCompose

并像这样设置 git 配置(如果没有设置)

git config — global user.name “Your Real Name”
git config — global user.email “you@example.com”

现在初始化repo

repo init -u https://android.googlesource.com/platform/manifest -b androidx-master-dev

repo 现已初始化,如果我们查看 ~/AndroidCompose 目录,我们将看到一个“.repo”列表

点击

ls -a ~/AndroidCompose/.repo

“现在您的存储库已设置为仅提取构建和运行 AndroidX 库所需的内容。下载代码(并在我们提取 6GB 时喝杯咖啡)”-Android 文档

Step 3: Command to get all required source

repo sync -j8 -c

(类似于 git fetch)

现在我们已经下载了包含@Composable 的正确版本的Android JetPack 源

这会将所有 Jetpack Compose 源放在“ui”目录中

cd ~/AndroidCompose/frameworks/support/ui

点击

./studio启动Android工作室

重启 Android Studio 时要小心。我们需要始终从该目录开始获取 Jetpack Compose 库。

出现提示时接受许可协议(protocol)。现在我们已准备好编辑、运行和测试!

关于android - Jetpack 撰写新源不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57789661/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com