Unable to call getChildFragmentManager on fragment

I am building an android project with maven. But I discovered when I call getChildFragmentManager in v4.Fragment , it shows an error that this method was not found. I doubt the support-v4 package is newer, because if I use ant to create my project, everything works fine.

However, I cannot include the new support-v4 in my project. Here is my pom.xml

 <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.meishixing</groupid> <artifactid>crazysight</artifactid> <version>1.0.0-snapshot</version> <packaging>apk</packaging> <name>crazysight</name> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <fest-assert.version>1.0.4</fest-assert.version> <junit.version>4.10</junit.version> <robolectric.version>2.0</robolectric.version> <intellij.annotations.version>12.0</intellij.annotations.version> </properties> <dependencies> <dependency> <groupid>com.google.android</groupid> <artifactid>android</artifactid> <version>4.1.1.4</version> <scope>provided</scope> </dependency> <dependency> <groupid>com.viewpagerindicator</groupid> <artifactid>library</artifactid> <version>2.4.1</version> <type>apklib</type> </dependency> <dependency> <groupid>com.tjerkw</groupid> <artifactid>slideexpandablelistview-library</artifactid> <version>1.1.0-snapshot</version> <type>apklib</type> </dependency> <dependency> <groupid>com.meishixing</groupid> <artifactid>android-async-http</artifactid> <version>1.4.2</version> <type>jar</type> </dependency> <dependency> <groupid>com.meishixing</groupid> <artifactid>baidu-locationp</artifactid> <version>3.3</version> <type>jar</type> </dependency> <dependency> <groupid>com.google.code.gson</groupid> <artifactid>gson</artifactid> <version>2.2.4</version> <scope>compile</scope> </dependency> <dependency> <groupid>org.apache.commons</groupid> <artifactid>commons-lang3</artifactid> <version>3.1</version> </dependency> <dependency> <groupid>com.github.chrisbanes.pulltorefresh</groupid> <artifactid>library</artifactid> <version>2.1.1</version> <type>apklib</type> </dependency> <dependency> <groupid>com.novoda.imageloader</groupid> <artifactid>imageloader-core</artifactid> <version>1.5.8</version> </dependency> </dependencies> <build> <finalname>${project.artifactid}</finalname> <sourcedirectory>src</sourcedirectory> <plugins> <plugin> <groupid>com.jayway.maven.plugins.android.generation2</groupid> <artifactid>android-maven-plugin</artifactid> <version>3.6.2-snapshot</version> <configuration> <sdk> <platform>17</platform> </sdk> <manifest> <debuggable>true</debuggable> </manifest> </configuration> <extensions>true</extensions> </plugin> </plugins> </build> </project> 
+4
source share
1 answer

I was shocked by this for several hours (which is why I also added generosity), but here is how I finally solved it.

First of all, check your dependencies on the path to the project using

 mvn dependency:build-classpath 

I could immediately see the problem on the output:

 <home>/.m2\repository\android\extras\android-support\v4\android-support-v4.jar <home>/.m2\repository\android\platforms\android\android-18\android-android-18.jar <home>/.m2\repository\com\actionbarsherlock\actionbarsherlock\4.4.0\actionbarsherlock-4.4.0.apklib <home>/.m2\repository\com\google\android\support-v4\r7\support-v4-r7.jar <... more jars> 

Two cans of support are included, and support-v4-r7.jar redefines my new android-support-v4.jar .

The older ActionBarSherlock was loaded in my project (in your project, any of the apklib dependencies may be the culprit), so I excluded it in the pom project:

 <dependency> <groupId>com.actionbarsherlock</groupId> <artifactId>actionbarsherlock</artifactId> <version>4.4.0</version> <type>apklib</type> <exclusions> <exclusion> <groupId>com.google.android</groupId> <artifactId>support-v4</artifactId> </exclusion> </exclusions> </dependency> 

Hope this helps someone.

+2
source

Source: https://habr.com/ru/post/1500544/


All Articles