当我单击运行时收到此消息:
> Failed to apply plugin 'com.android.internal.application'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
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`.
Run Code Online (Sandbox Code Playgroud)
错误消息“Android Gradle 插件需要 Java 11 才能运行。您当前正在使用 Java 1.8”的答案在设置中更改 Gradle JDK 有效。但仅限于那个项目。当我创建新项目时,Android Studio 会再次自动使用默认的 1.8。
我有 11 个可用,AS 只是不会自动使用它。我尝试过的事情:将 JAVA_HOME 环境更改为 JDK 11 的位置,但仍然出现相同的错误。
无效缓存/重新启动一段时间没有任何作用
附加 app/build.gradle
plugins {
id …Run Code Online (Sandbox Code Playgroud) 但ExampleInstrumentedTest 正在工作。
这是我的测试文件,我已经注释掉了所有内容,留下了一个空函数
@RunWith(AndroidJUnit4ClassRunner::class)
class ExploreFragmentTest {
@get: Rule
val activityRule = ActivityScenarioRule(MainActivity::class.java)
@Test
fun test_isSearchButtonDisplayed() {
//onView(withId(R.id.btn_search)).check(matches(isDisplayed()))
}
}
Run Code Online (Sandbox Code Playgroud)
这是我对 app/gradle 的依赖
// AndroidX Test - Instrumented testing
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
Run Code Online (Sandbox Code Playgroud)
在Android中,我想实现屏幕上固定高度的滚动视图,并且里面的内容也有固定的高度。
滚动视图高度为300dp,直接子级(相对布局)为500dp,文本视图距顶部的距离为301dp。这意味着在我到达文本视图后,还有 200dp 的底部空间供我从相对布局高度滚动。
我设法使用下面的 XML 创建所需的效果。
<ScrollView
android:layout_width="match_parent"
android:layout_height="300dp" >
<RelativeLayout
android:layout_width="match_parent"
android:background="#FFC0CB"
android:layout_height="500dp" >
<TextView
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:id="@+id/new_realm_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="301dp"
android:text="long text" />
</RelativeLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
但问题是,如果我将相对布局更改为约束布局,现在滚动只会向上滚动到高度为 310dp 的文本视图,而不是显示底部 200dp 的空白空间。
有人可以解释为什么约束布局给了我这种奇怪的行为吗?根据ConstraintLayout和RelativeLayout的区别,约束布局“兼具Relative布局和Linear布局的双重力量”,它应该能够实现相对布局能够实现的功能。
xml android scrollview android-relativelayout android-constraintlayout
位掩码0xaaaaaaaaaaaaaaaaL(16a's)在 kotlin 中超出或超出范围。如果我让 Android Sutdio 自动从 Java 转换,它会转换为-0x5555555555555556L,即101010101010101010101010101010101010101010101010101010101010110,它现在只有 63 位,末尾的 0110 已关闭。
0xaaaaaaaaaaaaaaaaL在 Java 中运行良好。我需要解释为什么它会出现-0x5555555555555556L在 kotlin 中。另外一个问题是kotlin如何表示负Long?为什么前面有-号?不是像Java中的2的补码吗?
我查看了文档https://kotlinlang.org/docs/basic-types.html#literal-constants,我知道 kotlin 支持十六进制语法。
我也尝试过 Unsigned Longval mask2: ULong = 0xaaaaaaaaaaaaaaaaL同样的问题。
提前致谢
我有一个类型的STL地图<string, int>,我需要将该地图复制到一个文件中,但我无法输入类型ostream_iterator
map<string, int> M;
ofstream out("file.txt");
copy( begin(M), end(M), ostream_iterator<string, int>(out , "\n") );
Run Code Online (Sandbox Code Playgroud)
错误消息错误:没有匹配函数来调用'std :: ostream_iterator,int> :: ostream_iterator(std :: ofstream&,const char [2])'|
既然地图M是一个类型,为什么ostream_iterator不采用它的类型呢?
android ×3
c++ ×1
c++11 ×1
gradle ×1
kotlin ×1
scrollview ×1
std ×1
stl ×1
ui-testing ×1
xml ×1