本文将介绍android–配置getByName在将POM文件发布到Artifactory时无法在gradle中工作的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同
本文将介绍android – 配置getByName在将POM文件发布到Artifactory时无法在gradle中工作的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于ActionBarDrawerToggle无法应用于Android.support.v7.widget.Toolbar、Android Error:Unable to find method ''com.android.build.gradle.api.BaseVariant.getOutputs()Lja...、android gradle: how to import a library module、Android Native Activity 的 gradle 配置的知识。
本文目录一览:- android – 配置getByName在将POM文件发布到Artifactory时无法在gradle中工作
- ActionBarDrawerToggle无法应用于Android.support.v7.widget.Toolbar
- Android Error:Unable to find method ''com.android.build.gradle.api.BaseVariant.getOutputs()Lja...
- android gradle: how to import a library module
- Android Native Activity 的 gradle 配置
android – 配置getByName在将POM文件发布到Artifactory时无法在gradle中工作
publishing { publications { aar(MavenPublication) { groupId packageName version = libraryVersion artifactId project.getName() // Tell maven to prepare the generated "*.aar" file for publishing artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") pom.withXml { def dependencies = asNode().appendNode('dependencies') configurations.getByName("_releaseCompile").getResolvedConfiguration().getFirstLevelModuleDependencies().each { def dependency = dependencies.appendNode('dependency') dependency.appendNode('groupId',it.moduleGroup) dependency.appendNode('artifactId',it.moduleName) dependency.appendNode('version',it.moduLeversion) } } } } }
它失败并出现以下错误:
Execution Failed for task ':smartcardsdk:generatePomFileForAarPublication'. > Could not apply withXml() to generated POM > Configuration with name '_releaseCompile' not found.
这对Android v2.x来说不是问题.我升级到Android Studio v3时出现问题(我猜Gradle v3.0.0也是如此).
我猜测配置不再与_releaseCompile名称一起存储.
有谁知道新的“名字”应该是什么?
谢谢.
解决方法
"releaseCompileClasspath"
ActionBarDrawerToggle无法应用于Android.support.v7.widget.Toolbar
错误说ActionBarDrawerToggle中的ActionBarDrawerToggle()无法应用于android.support.v7.widget.Toolbar然后在实际参数R.id.drawable_ic_drawer(int)下
import android.support.v7.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Bundle; import android.preference.PreferenceManager; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import android.support.v7.widget.Toolbar;
mDrawerToggle = new android.support.v7.app.ActionBarDrawerToggle( getActivity(),/* host Activity */ mDrawerLayout,/* DrawerLayout object */ R.drawable.ic_drawer,/* nav drawer image to replace 'Up' caret */ R.string.navigation_drawer_open,/* "open drawer" description for accessibility */ R.string.navigation_drawer_close /* "close drawer" description for accessibility */ ) {
据说造成错误的部分是R.drawer.ic_drawer.我该如何解决?
解决方法
android.support.v7.app.ActionBarDrawerToggle.ActionBarDrawerToggle(Activity activity,DrawerLayout drawerLayout,Toolbar toolbar,int openDrawerContentDescRes,int closeDrawerContentDescRes)
您正在传递R.drawable.ic_drawer drawable而不是工具栏,这就是您收到此错误的原因.
创建工具栏并将其添加为操作栏,并将此工具栏传递给此构造函数.
Android Error:Unable to find method ''com.android.build.gradle.api.BaseVariant.getOutputs()Lja...
问题:Error:Unable to find method ''com.android.build.gradle.api.BaseVariant.getOutputs () Ljava/util/List;''.
Possible causes for this unexpected error include:<ul><li>Gradle''s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
build.gradle 如下:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath ''com.android.tools.build:gradle:3.0.0''
classpath ''com.jakewharton:butterknife-gradle-plugin:8.4.0''
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
查阅了很久发现其实是 Android Studio3.0 与 butterknife 的冲突,github 上面已经有了这个问题 issue,JakeWharton 大神也给了相关解释,暂时的解决方法是降至 8.4 的版本。
android gradle: how to import a library module
Sometimes you finish an module and you want to reuse the code for other application, following steps may help!
1, Copy the module sources folder into the root of project you developing;
2, Follow this guide to config build.gradle file of your module: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-projects, ;
3, (Using idea intellij) File-> new-> module from existing sources, select the module folder you just copied-> click finish. If any errors reported, config build.gradle of the imported module to get rid of them.
4, Add module name to "settings.gradle" file which locates in project root. For example I want to import a moudle called "swipelistview":
include '':app'', '':swipelistview''.
5, Add depency to "build.gradle" file of the main module, like this:
dependencies {
compile project('':swipelistview'')
}
6, rebuild your project!
Android Native Activity 的 gradle 配置
实例项目的module结构
app module 的 manifests,其中android:value=”native-activity”与nativeactivity的build.gradle中的moduleName对应
<?xml version="1.0" encoding="utf-8"?><!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.native_activity"
android:versionCode="1"
android:versionName="1.0">
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:hasCode="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity
android:name="android.app.NativeActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name">
<!-- Tell NativeActivity the name of or .so -->
<meta-data
android:name="android.app.lib_name"
android:value="native-activity" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest><!-- END_INCLUDE(manifest) -->
native module的manifests
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.foohao.nativeactivity">
<application/>
</manifest>
项目的build.gradle
// Top-level build file where you can add
// configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath ''com.android.tools.build:gradle-experimental:0.7.0''
}
}
allprojects {
repositories {
jcenter()
}
}
app module的 build.gradle
apply plugin: ''com.android.model.application''
model {
android {
compileSdkVersion = 23
buildToolsVersion = ''23.0.3''
defaultConfig {
applicationId = ''com.example.native_activity''
minSdkVersion.apiLevel = 18
targetSdkVersion.apiLevel = 23
}
ndk {
platformVersion = 18
moduleName =''native-activity''
toolchain = ''gcc''
stl = ''gnustl_static''
cppFlags.add(''-std=c++11'')
ldLibs.addAll([''log'', ''android'', ''EGL'', ''GLESv1_CM''])
}
sources {
main {
jni {
dependencies {
project '':nativeactivity'' linkage ''static''
}
}
}
}
buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file(''proguard-rules.txt''))
}
}
}
}
nativeactivity module的 build.gradle
apply plugin: ''com.android.model.library''
def ndkDir = System.getenv("ANDROID_NDK_HOME")
def propertiesFile = project.rootProject.file(''local.properties'')
if (propertiesFile.exists()) {
Properties properties = new Properties()
properties.load(propertiesFile.newDataInputStream())
ndkDir = properties.getProperty(''ndk.dir'')
}
model {
android {
compileSdkVersion = 23
buildToolsVersion = "23.0.3"
defaultConfig.with {
minSdkVersion.apiLevel = 18
targetSdkVersion.apiLevel = 23
versionCode = 1
versionName = "0.0.1"
}
ndk {
moduleName = ''native-activity''
toolchain = ''gcc''
ldLibs.addAll([''log'', ''android''])
ldFlags.add("-c")
}
sources {
main {
jni {
source {
srcDir "${ndkDir}/sources/android/native_app_glue"
}
exportedHeaders {
srcDir "${ndkDir}/sources/android/native_app_glue"
}
}
}
}
}
}
今天关于android – 配置getByName在将POM文件发布到Artifactory时无法在gradle中工作的介绍到此结束,谢谢您的阅读,有关ActionBarDrawerToggle无法应用于Android.support.v7.widget.Toolbar、Android Error:Unable to find method ''com.android.build.gradle.api.BaseVariant.getOutputs()Lja...、android gradle: how to import a library module、Android Native Activity 的 gradle 配置等更多相关知识的信息可以在本站进行查询。
本文标签: