我一直在尝试使用 Android 的 Baseline Profile 和 MacroBenchmark 库来提高应用程序性能。
我的问题是,建议MacroBenchmark 的构建类型尽可能接近构建release,但符合-dontobfuscateproguard 规则。
如果生产应用程序将通过obfuscated,minification那么 Baseline Profiler 如何帮助提高应用程序性能,因为baseline-prof.txt应用程序classes.dex文件中的类可能完全不同。
Profiler 和 Proguard/R8 之间是否存在某种内部映射?
我会以编程方式创建一个按照设计指南中定义的按钮:https://material.io/design/components/buttons.html#outlined-button,如下所示:
在XML中我可以使用这段布局xml来做到这一点:
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonGetStarted"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:text="@string/title_short_intro" />
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是一个示例,说明如何使用Java代码执行此操作?我尝试过以下方法:
MaterialButton testSignIn = new MaterialButton( new ContextThemeWrapper( this, R.style.Widget_MaterialComponents_Button_OutlinedButton));
String buttonText = "Sign-in & empty test account";
testSignIn.setText( buttonText );
Run Code Online (Sandbox Code Playgroud)
但这不会导致大纲变体:
使用Android Studio菜单选项“重构->重构到Androidx”迁移到Androidx程序包后...
我的build.gradle看起来像
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
Run Code Online (Sandbox Code Playgroud)
在运行应用程序期间,我遇到了这个问题:
Didn't find class "androidx.core.widget.DrawerLayout"
Run Code Online (Sandbox Code Playgroud)
看来迁移工具也有同样的问题
我正在玩预览版AndroidStudio - 3.4 Canary 9.
我从Configure your project窗口中选择了默认登录活动选项并提供了以下选项:
Gradle同步没有报告错误,但是在构建编译时它会产生以下错误:
Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
Run Code Online (Sandbox Code Playgroud)
以下是显示错误的代码段:
// Type mismatch at this@LoginActivity, required LifeCycleOwner, found - LoginActivity
loginViewModel.loginFormState.observe(this@LoginActivity, Observer {
val loginState = it ?: return@Observer
// disable login button unless both username / password is valid
login.isEnabled = loginState.isDataValid
if (loginState.usernameError != null) {
username.error = getString(loginState.usernameError)
}
if (loginState.passwordError != null) {
password.error = getString(loginState.passwordError)
}
})
Run Code Online (Sandbox Code Playgroud)
LoginActivity 源于 AppCompatActivity()
各自进口的图书馆是 …
kotlin android-architecture-components android-jetpack androidx android-studio-3.4
我正在使用Dagger 2.21,而当我尝试这样做时
@Module
internal abstract class FragmentModule {
@ContributesAndroidInjector
internal abstract fun loginFragment() : LoginFragment
}
Run Code Online (Sandbox Code Playgroud)
和
@Singleton
@Component(modules = [AndroidSupportInjectionModule::class, AppModule::class, ActivityModule::class, ViewModelBuilder::class, ViewModelModule::class, RepositoriesModule::class, ApiModule::class, FragmentModule::class])
interface AppComponent : AndroidInjector<PhotocoApplication> {
@Component.Builder
abstract class Builder : AndroidInjector.Builder<PhotocoApplication>()
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
/app/build/generation/source/kapt/debug/com/photoco/app/injection/module/FragmentModule_LoginFragment$app_debug.java:18:错误:不兼容的类型:类LoginFragment无法转换为类扩展Fragment
我一直在搜索,发现使用2.21并将其设置为可以正常工作,但还没有运气
android.useAndroidX = true; android.enableJetifier = true
LoginFragment扩展:
dagger.android.support.DaggerFragment()
由于所有这些设置无法构建,我在这里缺少什么吗?我可以使用DaggerActivity使其与Activity一起使用,但不能与Fragments一起使用。
PhotocoApplication扩展了dagger.android.support.DaggerApplication
谢谢!
如果添加以下行,则在创建新的Android Studio项目(“空活动”类型)后:
// Lifecycle/View Models
def lifecycleVersion = '2.0.0'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycleVersion"
// Core testing
def coreTestingVersion = '2.0.1'
testImplementation "androidx.arch.core:core-testing:$coreTestingVersion"
androidTestImplementation "androidx.arch.core:core-testing:$coreTestingVersion"
Run Code Online (Sandbox Code Playgroud)
对于应用程序的build.gradle文件,当您尝试运行connectedCheck项目任务时会看到错误。查看输出:
Zachs-MBP:CoreTestingVersionExample Zach$ ./gradlew connectedCheck
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugAndroidTestBuild'.
> Could not resolve all task dependencies for configuration ':app:debugAndroidTestRuntimeClasspath'.
> Could not resolve androidx.arch.core:core-common:2.0.0.
Required by:
project :app
> Cannot find a version of 'androidx.arch.core:core-common' that satisfies the …Run Code Online (Sandbox Code Playgroud) 我已经将React Native更新为0.60-RC2,使用Android Studio折射器迁移到AndroidX并使用了此处提到的喷射器:https : //github.com/react-native-community/discussions-and-proposals/issues/129
完成此操作后,我library "libjsc.so" not found在运行时收到错误消息react-native run-android。运行发行版APK时出现相同错误。
stacktrace是:
06-24 15:55:01.823 8579 8656 E SoLoader: Error when loading lib: dlopen failed: library "libjsc.so" not found lib hash: 83f1717c1dc187d9f252a9f1fc66d430 search path is /data/app/com.jtv.testapp-4hvCKbqEmbyyOPykuQhm4Q==/lib/arm
06-24 15:55:01.823 8579 8656 E SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found
06-24 15:55:01.825 8579 8656 E AndroidRuntime: FATAL EXCEPTION: create_react_context
06-24 15:55:01.825 8579 8656 E AndroidRuntime: Process: com.jtv.testapp, PID: 8579
06-24 15:55:01.825 …Run Code Online (Sandbox Code Playgroud) 很奇怪为什么 fontFamily 不能在 androidX 上工作。
这是我的代码:
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:text="testing "
android:textSize="17sp"
android:fontFamily="@font/iransans"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Run Code Online (Sandbox Code Playgroud)
上面的代码根本不影响字体,当我将 textview 转换为 app compact 时,它可以工作:
<androidx.appcompat.widget.AppCompatTextView
Run Code Online (Sandbox Code Playgroud)
我想设置我的整个应用程序字体,但它不像我预期的那样工作:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">@font/iransans</item>
</style>
Run Code Online (Sandbox Code Playgroud)
有什么办法可以解决这个问题吗?如何在不为每个视图设置字体系列的情况下在整个应用程序中使用我的字体?
我有一个 MotionScene,其中有 4 个 ConstraintSet,代表屏幕的 4 个状态(加载状态),并且它们之间有 3 个转换。当我的应用程序状态从例如加载更改为处理时,我想运行转换 1 (set1 -> set2),当状态再次更改时,我想运行转换 2 (set2 -> set3)。我找不到办法做到这一点。
我接下来尝试:
设置当前转换
motion_layout.setTransition(R.id.set1, R.id.set2)
motion_layout.transitionToState(R.id.set2)
Run Code Online (Sandbox Code Playgroud)
只设置过渡
motion_layout.setTransition(R.id.set1)
Run Code Online (Sandbox Code Playgroud)
转换到某种状态:
motion_layout.transitionToState(R.id.set1)
Run Code Online (Sandbox Code Playgroud)
但是上述所有方法都运行我的所有集合,即使我使用 app:autoTransition="none" 。
我尝试将所有内容都放在一个 Transition 中并设置 app:progress = 0 on ,然后通过进度控制动画状态:
motion_layout.setProgress(0.25f, 1.0f)
Run Code Online (Sandbox Code Playgroud)
它只是将所有动画运行到最后,或者我尝试过
motion_layout.progress = 0.25f
Run Code Online (Sandbox Code Playgroud)
它没有动画,它只向我显示 0.25 动画进度,没有任何动作。
如何控制动画的流向?如何运行特定的集合?使用进步会更好吗?如何解决?
PS我用
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta7'
Run Code Online (Sandbox Code Playgroud) animation android android-constraintlayout androidx android-motionlayout
我找不到如何链接我Text()使用的 Jetpack Compose。
在撰写之前我要做的就是:
Linkify.addLinks(myTextView, Linkify.EMAIL_ADDRESSES or Linkify.WEB_URLS)
显然,我的 TextView 中包含的所有链接都变成了可点击的链接。
重要提示:文本内容来自 API,链接没有固定位置,内容可能包含多个链接。
我想通过使用 Jetpack Compose 来保持这种行为,但我找不到任何有关这样做的信息。
有人知道吗?
android kotlin android-jetpack androidx android-jetpack-compose
androidx ×10
android ×9
kotlin ×3
android-architecture-components ×1
android-r8 ×1
animation ×1
dagger-2 ×1
gradle ×1
proguard ×1
react-native ×1