In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "how to solve the incompatibility of the version of Android after adding fragment". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
The emergence and introduction of Fragment
Android runs on a variety of devices, including phones with small screens, tablets with oversized screens and even televisions. In view of the gap in screen size, in many cases, we first develop a set of App for the phone, and then make a copy and modify the layout to adapt to the super large screen of the tablet. Is it impossible for an App to adapt to both a mobile phone and a tablet? of course, there must be. The emergence of Fragment is to solve such problems. You can think of Fragment as a part of an interface of Activity, and even the interface of Activity can be composed of completely different Fragment, what is more handsome is that Fragment has its own life cycle and receives and handles user events, so that you don't have to write a bunch of control event handling code in Activity. More importantly, you can add, replace, and remove Fragment dynamically.
I learned the Fragment of Android yesterday. According to the tutorial on the official website, a new class BlankFragment is created, which inherits from Fragment. Then there was an error when compiling:
Error:Execution failed for task': app:processDebugManifest'. > Manifest merger failed: Attribute meta-data#android.support.VERSION@value value= (26.0.0-beta1) from [com.android.support:design:26.0.0-beta1] AndroidManifest.xml:28:13-41 is also present at [com.android.support:support-v4:26.1.0] AndroidManifest.xml:28:13-35 value= (26.1.0). Suggestion: add 'tools:replace= "android:value"' to element at AndroidManifest.xml:26:9-28:44 to override.
After searching, seven, seven, eight, seven, eight, seven, seven, eight, eight, anything. One of the most unreliable things is to change the tags in manifest files from android:name to class. Look at the log is obviously related to the version ah! Finally, we found a solution related to version compatibility. You need to add the following code to build.gradle in the app directory:
Configurations.all {resolutionStrategy.eachDependency {DependencyResolveDetails details-> def requested = details.requested if (requested.group = = 'com.android.support') {if (! requested.name.startsWith ("multidex")) {details.useVersion' 26.0.0Muta1'}
It was good to give it a try. But not satisfied with that.
Notice that just above the added code, it describes the libraries that the project depends on:
Dependencies {implementation fileTree (dir: 'libs' Include: ['* .jar']) implementation 'com.android.support:appcompat-v7:26.0.0-beta1' implementation' com.android.support.constraint:constraint-layout:1.0.2' implementation 'com.android.support:design:26.0.0-beta1' implementation' com.android.support:support-v4:26.1.0' testImplementation 'junit:junit:4.12' androidTestImplementation' com.android.support.test:runner:0.5' AndroidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'}
And there is a red line under this line:
Implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
The mouse finger goes up to prompt:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.1.0, 26.0.0-beta1. Examples include com.android.support:support-compat:26.1.0 and com.android.support:animated-vector-drawable:26.0.0-beta1
This is not very clear: all libraries that rely on com.android.support must use the same version! Look at Dependency, com.android.support:appcompat-v7:26.0.0-beta1 and com.android.support:support-v4:26.1.0 two versions are contradictory ah! Take a look at the record of git. The line 26.1.0 is newly added, which must be automatically added by AndroidStudio when you create a new BlankFragment class. Looking back at the error log, doesn't it mean the same thing?
This is the end of the content of "how to solve the incompatibility after adding fragment to Android". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.