安卓工作室 3.6。
我希望我的应用程序始终处于portrait
模式。所以在我的AndroidMainfest.xml
:
<activity
android:name=".activity.SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
我运行该应用程序并SplashActivity
以portrait
模式显示。好的。但是编辑器显示以下错误:
Expecting android:screenOrientation="unspecified"
Run Code Online (Sandbox Code Playgroud)
为什么?
安卓工作室 3.6
在 app/build.gradle 中:
android {
viewBinding.enabled = true
Run Code Online (Sandbox Code Playgroud)
这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bluetoothBottonMainContainer"
android:layout_width="0dp"
android:layout_height="104dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="@+id/viewPointNotSelect"
android:layout_width="16dp"
android:layout_height="16dp"
android:background="@drawable/circle_transparent"
app:layout_constraintBottom_toBottomOf="@+id/separator"
app:layout_constraintEnd_toStartOf="@+id/separator"
app:layout_constraintTop_toTopOf="parent" />
Run Code Online (Sandbox Code Playgroud)
和另一个 xml unclude prev。xml:
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bottonContainer"
android:layout_width="0dp"
android:layout_height="104dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<include
android:id="@+id/qrBottonContainer"
layout="@layout/qr_bottom_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
Run Code Online (Sandbox Code Playgroud)
这是我的活动:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = QrBluetoothSwipeActivityBinding.inflate(layoutInflater)
setContentView(binding.root)
}
Run Code Online (Sandbox Code Playgroud)
该应用程序正在构建和运行。好的。
现在我移动 id - android:id="@+id/bluetoothBottonMainContainer"
到这样的外部容器:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" …
Run Code Online (Sandbox Code Playgroud) 在我的Spring Boot 2项目中:
在build.gradle
:
dependencies {
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.h2database:h2'
implementation 'javax.servlet:jstl:1.2'
implementation 'org.springframework.boot:spring-boot-devtools'
implementation('org.springframework.boot:spring-boot-starter') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
}
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-log4j2'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation "org.springframework.boot:spring-boot-starter-web"
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
}
Run Code Online (Sandbox Code Playgroud)
在src/resources/log4j2.xml
:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="Console"
class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<!-- l, L, M - is extremely slow. It's use …
Run Code Online (Sandbox Code Playgroud) 安卓工作室 3.6。金丝雀 12
构建.gradle:
buildscript {
ext.kotlin_version = '1.3.50'
ext.RETROFIT_VERSION = '2.6.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0-alpha12'
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
}
}
Run Code Online (Sandbox Code Playgroud)
在 app/build.gradle 中:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
android {
viewBinding {
enabled = true
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion …
Run Code Online (Sandbox Code Playgroud) android android-databinding android-studio-3.6 android-viewbinding
通过 build.gradle 构建 Kotlin 项目成功:
compileKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
compileTestKotlin {
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
}
Run Code Online (Sandbox Code Playgroud)
好的。
但我需要更改为build.gradle.kts:
plugins {
kotlin("jvm") version "1.2.10"
id("application")
}
group = "com.myproject"
version = "1.0-SNAPSHOT"
application {
mainClassName = "MainKt"
}
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
jcenter()
}
val kotlinVer = "1.2.10"
dependencies {
compile(kotlin(module = "stdlib-jre8", version = kotlinVer))
implementation("com.google.code.gson:gson:2.7")
implementation("com.squareup.okhttp3:logging-interceptor:3.8.0")
implementation("com.squareup.retrofit2:converter-gson:2.1.0")
implementation("com.squareup.retrofit2:retrofit:2.5.0")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Run Code Online (Sandbox Code Playgroud)
现在我得到错误:
Line …
Run Code Online (Sandbox Code Playgroud) 我尝试为 android 运行 Kotlin 仪器测试。
在我的 app/build.gradle 中:
android {
dataBinding {
enabled = true
}
compileSdkVersion 28
defaultConfig {
applicationId "com.myproject"
minSdkVersion 18
targetSdkVersion 28
versionCode 6
versionName "0.0.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
androidTest.java.srcDirs += 'src/androidTest/kotlin'
}
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test:rules:1.1.2-alpha02'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha02'
Run Code Online (Sandbox Code Playgroud)
在文件夹中/app/src/androidTest/kotlin/com/myproject/
我有 Kotlin 测试:
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import org.junit.Rule
import org.junit.runner.RunWith
import androidx.test.rule.ActivityTestRule
import com.myproject.ui.activity.TradersActivity
import org.junit.Before
@RunWith(AndroidJUnit4::class)
@SmallTest
class TradersActivityTest {
private lateinit var stringToBetyped: String
@get:Rule …
Run Code Online (Sandbox Code Playgroud) 当我使用Android Studio 3.0并使用下一版本的build:gradle in project/build.gradle
:
classpath 'com.android.tools.build:gradle:3.0.1'
Run Code Online (Sandbox Code Playgroud)
它工作正常.我更新到Android Studio 3.1后,结果我更新build:gradle:
classpath 'com.android.tools.build:gradle:3.1.0'
Run Code Online (Sandbox Code Playgroud)
现在我的错误在于app/build.gradle
:
def releaseFileName = "${rootProject.name}_${defaultConfig.versionName}.apk"
outputFileName = new File(rootProject.projectDir.absolutePath + "/release", releaseFileName.toLowerCase())
Run Code Online (Sandbox Code Playgroud)
错误:
设置输出文件名时不支持绝对路径
我需要将输出apk(app-release.apk
)放在项目的特定路径中.在文件夹中MyProject/release/app-relese.apk
.我怎么能这样做?
Windows 7的.
如果我想在文件中找到一些文本我使用下一个命令(来自windows shell)
findstr "find_this" trace.log
Run Code Online (Sandbox Code Playgroud)
结果打印内容文本"find_this"的所有行.好.但我需要打印前3行和找到行后3行.我如何通过命令findstr来做到这一点?
在Unix上,我可以通过"grep"来做到这一点
grep -B 3 -A 3 find_this trace.log
Run Code Online (Sandbox Code Playgroud)
但我如何在Windows上执行此操作?
Android Studio 2.3.3,Java 8
我为Android 4.0+创建Android应用程序
在我的app/build.gradle中:
...
minSdkVersion 15
targetSdkVersion 26
Run Code Online (Sandbox Code Playgroud)
我想使用默认接口实现(来自Java 8).所以我创建了tnext类:
public interface DefaultCallback {
public default void onResponse(Call<T> var1, Response<T> var2) {
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到编译错误:
默认方法要求API级别24(当前最小值为15)
所以问题是:
我可以在Android <API 24上使用deafult接口实现吗?
在我的 android 应用程序中,如果我想更新 APK 文件,我使用这个:
adb install -r some_my.apk
Run Code Online (Sandbox Code Playgroud)
好的。这是工作。现在我签署了我的包,结果是 Android Studio 3.5。生成:AAB(Android App Bundle)文件。好的。
现在我从 Google Play 安装 prev 应用程序。我想通过AAB更新我的应用程序。
我怎么能做到这一点?
如果我试试这个:
adb install -r some_my.aab
Run Code Online (Sandbox Code Playgroud)
我得到错误:
adb.exe: need APK file on command line
Run Code Online (Sandbox Code Playgroud)