Android Studio 0.4.2工作正常,今天我打开它,几乎所有东西都是红色,自动完成已停止工作.我看看导入和AS似乎告诉我它突然找不到android.support.v4(提供我删除未使用的导入的选项).(android.support.v7似乎很好).
我尝试过的事情:
在这里它是相关的:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
}
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.android.support:gridlayout-v7:19.0.0'
compile 'com.android.support:appcompat-v7:19.0.0'
compile 'com.google.android.gms:play-services:4.0.30'
compile project(':libraries:facebook')
compile files('libs/core.jar')
}
Run Code Online (Sandbox Code Playgroud)
当我点击"与Gradle同步"并打开"项目设置"时,我收到一个红色错误,告诉我我有重复的库引用并删除未使用的库引用.

我的项目编译并运行良好,但我真的需要自动完成工作!有没有人有什么建议?

我经常需要在编写代码时使用文本编辑器粘贴随机笔记,尤其是JSON响应,我使用插件格式化它们(对于Sublime).
我最近听说IntelliJ/Android Studio中的'临时文件'功能完全符合我的需要 - 除了我不能使它格式化JSON我很好地粘贴.
如何在临时缓冲区文件中制作Android Studio格式的JSON?
当前的文档没有提到这个非常重要的按钮已被删除。我想这与它现在跟踪流程的方式不同有关。它在哪里?我们现在必须通过 adb 自己杀死进程吗?为什么它移动了?为什么没人讨论这个?!
Android Studio 2.1版,gradle版本2.1.0,如果你发现任何曲解,请纠正我:)
我对支持库23.3.0中的支持向量感到困惑.具体来说,我想要的是以编程方式设置图像按钮,其src被定义为矢量drawable.据我所知,这在前棒棒糖上是不可能的.
我已经阅读了几篇关于这些变化的相关帖子: 23.2.0公告和变更:
从Android支持库23.3.0开始,支持向量drawable只能通过app:srcCompat或setImageResource()加载.
是否以上意味着矢量个XML只能通过srcCompat或setImageResource()被用于预棒棒糖,因此不能动态着色?
这是我的基本图像按钮:
<ImageButton
android:id="@+id/nav_header_exit_community_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="@null"/>
Run Code Online (Sandbox Code Playgroud)
仅适用于棒棒糖及以上:
Drawable bg = ContextCompat.getDrawable(a, R.drawable.ic_exit_to_app_24dp);
DrawableCompat.setTint(bg, headerTitleColor);
exitButton.setImageDrawable(bg);
Run Code Online (Sandbox Code Playgroud)
试图这个前棒棒糖投掷:
android.content.res.Resources$NotFoundException: File res/drawable/ic_exit_to_app_24dp.xml from drawable resource ID #0x7f0200bf
也适用于棒棒糖及以上
Drawable bg = ContextCompat.getDrawable(a, R.drawable.ic_exit_to_app_24dp);
DrawableCompat.setTint(bg, headerTitleColor);
exitButton.setImageResource(R.drawable.ic_exit_to_app_24dp);
Run Code Online (Sandbox Code Playgroud)
这会给前Lollipop带来同样的错误.
但是,如果我删除vectorDrawables.useSupportLibrary = true的指出,由伊恩·湖这里,与具有生成工具自动生成预棒棒糖设备png格式,的意图的PNG图像不会在预棒棒糖着色,所以我又回到了起点.
我也试图通过指定载体srcCompat和编程检索,但我不认为我已经能够做到这一点,尽管它适用于后棒棒糖如果使用指定的载体src来代替.
所以23.3.0的情况似乎是:
Post-Lollipop:src和srcCompat接受向量,只能src从视图中检索为可绘制的用于编程的着色.使用getDrawable可以在代码中引用向量,并且可以对它们进行着色.
Pre-Lollipop:srcCompat只能接受向量,不能从视图中以编程方式检索. setImageResource可以接受矢量,但仅限于vectorDrawables.useSupportLibrary = false,并且着色不起作用.类似地,代码中的引用向量是不可能的,除非vectorDrawables.useSupportLibrary = false并且着色不起作用. …
我最近安装了最新的Canary版本的Android Studio,目前正在使用Android Gradle插件3.0.0-alpha4(之前的版本2.3.3).
我现在收到所有buildConfigFields的警告:
buildTypes {
def BOOLEAN = "boolean"
def STRING = "String"
def INT = "int"
def TRUE = "true"
def FALSE = "false"
def SOME_PER_BUILD_TYPE_FIELD = "SOME_PER_BUILD_TYPE_FIELD"
debug {
buildConfigField BOOLEAN, SOME_PER_BUILD_TYPE_FIELD, FALSE
}
release {
buildConfigField BOOLEAN, SOME_PER_BUILD_TYPE_FIELD, TRUE
}
Run Code Online (Sandbox Code Playgroud)
警告内容如下:
Warning:BuildType(debug): buildConfigField 'SOME_PER_BUILD_TYPE_FIELD' value is being replaced: false -> false
Warning:BuildType(debug): buildConfigField 'SOME_STRING_FIELD' value is being replaced: "999" -> "999"
Run Code Online (Sandbox Code Playgroud)
对于我的各种领域和构建类型,其中有100个.我如何解决它们以及实际告诉我的警告是什么?
我的应用程序有一个活动,每个部分都有不同的片段.我最近通过设置fitSystemWindows为状态栏半透明,将true其设置为应用程序的背景颜色.这适用于具有工具栏的片段,颜色匹配,如下所示:

然而,我的一个片段有一张照片和一个半透明的工具栏,所以我想让照片占据状态栏的空间,而不是背景颜色.
我认为,解决的办法是设置fitSystemWindows到false了只有片段,并手动添加填充到半透明的工具栏.以编程方式执行此操作似乎没有任何效果,我可能做错了什么?
这是我的主要活动布局:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_parent_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<!-- Container for various fragment layouts, including nav drawer and tool bar -->
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
从我的片段的onCreateView()中:
RelativeLayout daddyLayout = (RelativeLayout)getActivity().findViewById(R.id.main_parent_view);
daddyLayout.setFitsSystemWindows(false);
daddyLayout.invalidate();
Run Code Online (Sandbox Code Playgroud)
这似乎没有效果,如下:

如果我在中设置fitSystemWindows为false main_parent_view,状态栏填充消失了它可以工作,但显然会影响每个片段.
android android-layout android-fragments android-view android-styles
:app:kaptDebugKotlin
w: warning: The following options were not recognized by any processor: '[kapt.kotlin.generated, room.incremental]'
Run Code Online (Sandbox Code Playgroud)
为什么我得到这个?我在一个多模块项目中使用 Room。
共享库模块:
api "androidx.room:room-runtime:$room_version"
api "androidx.room:room-ktx:$room_version"
api "androidx.room:room-rxjava2:$room_version"
应用模块:
kapt "androidx.room:room-compiler:$room_version"
Gradle.properties
kapt.incremental.apt=true
Run Code Online (Sandbox Code Playgroud)
Build.gradle defaultConfig 包括这些编译选项:
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.incremental":"true"]
}
}
Run Code Online (Sandbox Code Playgroud) 这是一个非常奇怪的.今天AS(1.4)在我的项目中停止正确地重新创建调试apk:
我对构建过程并不是很了解,所以我所尝试的就是删除构建文件夹,在Android Studio上重新导入项目和旧的重启/无效缓存.关于什么可能导致这种奇怪的行为或如何解决它的任何建议?
编辑: 很难确定这背后的行为 - 有时我注意到它一直只影响某些xml文件.看起来这个人有同样的问题:Android Studio项目构建问题
我花了几个小时从头开始重新安装Android Studio,问题仍然存在.
我正在努力学习匕首和kotlin和mvvm,如果这个问题很奇怪,请原谅我.
如果我有一个NetworkModule,它基本上为应用程序提供了改进,我认为传递我们想要构建改造的基本URL是个好主意.我可以通过App的组件构建函数传递它,以旧的方式,但无法通过@ Component.Builder方法弄清楚如何做到这一点.尝试:
App.kt
DaggerAppComponent.builder()
.application(this)
.networkModule(BuildConfig.BASE_URL)
.build()
.inject(this)
Run Code Online (Sandbox Code Playgroud)
AppComponent.kt
@Singleton
@Component(modules = arrayOf(
AppModule::class,
NetworkModule::class,
AndroidInjectionModule::class,
ActivityBuilder::class))
interface AppComponent {
@Component.Builder
interface Builder {
@BindsInstance
fun application(application: Application): Builder
@BindsInstance
fun networkModule(baseUrl: String): Builder
fun build(): AppComponent
}
fun inject(app: App)
}
Run Code Online (Sandbox Code Playgroud)
NetworkModule.kt
@Module
class NetworkModule(baseUrl: String) {
//Attempt to force a public setter for Dagger
var baseUrl: String = baseUrl
set
@Provides
@Singleton
fun provideHttpLoggingInterceptor(): HttpLoggingInterceptor {
val loggingInterceptor = HttpLoggingInterceptor { message -> …Run Code Online (Sandbox Code Playgroud) 我正在学习数据绑定和mvvm.我有一个问题,我希望BaseViewModel.kt包含一些与UI相关的变量,如isLoading标志和loadingText.当发出网络请求时,我设置isLoading为true,我的基本视图模型的一些子项应该设置文本.例如,LoginViewModel.kt文本可能是"登录".是否可以将这些变量传递给包含的基本布局?
所以login_activity.xml可能在它的布局中包含这个:
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="core.sdk.ui.login.LoginViewModel" />
</data>
<!-- Various click listeners using the viewModel variable -->
<include
android:id="@+id/progress_include"
layout="@layout/progress_bar"
android:visibility="@{viewModel.isLoading ? View.VISIBLE : View.GONE}"
bind:viewModel="@{viewModel}"/>
Run Code Online (Sandbox Code Playgroud)
现在我想让我progress_bar.xml变得漂亮和通用并使用基本视图模型:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="core.sdk.ui.login.LoginActivity">
<data>
<import type="android.view.View" />
<variable
name="viewModel"
type="core.sdk.ui.base.BaseViewModel" />
</data>
<LinearLayout
android:id="@+id/circular_progress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<android.support.v4.widget.ContentLoadingProgressBar
style="@style/Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/progress_text"
style="@style/TextAppearance.AppCompat.Subhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-thin"
android:gravity="center_horizontal"
android:text="@{viewModel.loadingText}"
android:textStyle="italic"
tools:text="loading..." /> …Run Code Online (Sandbox Code Playgroud) android ×8
kotlin ×2
android-room ×1
android-view ×1
android-xml ×1
build.gradle ×1
dagger-2 ×1
gradle ×1
import ×1
json ×1
kapt ×1
logcat ×1