title: Fragment Compatibility onActivityResult() Not Working
body: <p>I have been working on an application for android that utilizes the android comparability library (android-support-v4). Before SDK 20, I was able to compile my application with the following <code>uses-sdk</code> entry in my manifest. </p>
  
  <pre><code>&lt;uses-sdk android:minSdkVersion="7" /&gt;  
  </code></pre>
  
  <p>All my fragments that started an activity for result received their results properly.</p>
  
  <p>One day (Before I updated to SDK 20) I was fixing lint issues, and I added <code>android:targetSdkVersion</code> to the manifest per the lint flag's request, and I soon realized that none of my fragments were receiving their onActivityResilt() calls.</p>
  
  <p>Now every since I have updated to SDK 20.0.1, I am forced to utilize the <code>android:targetSdkVersion</code> in <code>uses-sdk</code> entry in my manifest; otherwise R.java is never generated.</p>
  
  <p>Here is my current <code>uses-sdk</code> manifest entry</p>
  
  <pre><code>&lt;uses-sdk
      android:minSdkVersion="7"
      android:targetSdkVersion="16" /&gt;
  </code></pre>
  
  <p>Currently because of this odd bug, my application is currently still broken. 
  I have tryied updating my compatibly library the the latest version r9.</p>
  
  <p>Also I have double checked all my <code>startActivityForResult()</code> calls in the fragments. They all use the proper calls through the fragment's method. </p>
  
  <p><strong>i.e.</strong> </p>
  
  <pre><code> this.startActivityForResult(intent, requestCode);
  </code></pre>
  
  <p><strong>not</strong></p>
  
  <pre><code> this.getActivity().startActivityForResult(intent, requestCode);
  </code></pre>
  
  <p>My current Development Environment:</p>
  
  <pre><code>Android SDK 20.0.1
  Android SDK Platform Tools 13
  ADT 20.0.2
  </code></pre>
  
  <p>Any help would be greatly appreciated, as this bug is currently the brick wall that is preventing my final beta tests.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's my output of <code>ant debug</code></p>
  
  <blockquote>
    <p>$ ant debug 
    Buildfile:
    /home/ricky/Development/workspace/location_ringer/LocationRinger/build.xml</p>
    
    <p>-set-mode-check:</p>
    
    <p>-set-debug-files:</p>
    
    <p>-check-env:  [checkenv] Android SDK Tools Revision 20.0.1  [checkenv] Installed at /app/android-sdk-linux_86</p>
    
    <p>-setup:
         [echo] Project Name: ListActivity   [gettype] Project Type: Application</p>
    
    <p>-set-debug-mode:</p>
    
    <p>-debug-obfuscation-check:</p>
    
    <p>-build-setup:
         [echo] Resolving Build Target for ListActivity... [gettarget] Project Target:   Google APIs [gettarget] Vendor:           Google
    Inc. [gettarget] Platform Version: 4.1 [gettarget] API level:<br>
    16
         [echo] ----------
         [echo] Creating output directories if needed...
         [echo] ----------
         [echo] Resolving Dependencies for ListActivity... [dependency] Library dependencies: [dependency]  [dependency] ------------------
    [dependency] Ordered libraries: [dependency]  [dependency]
    ------------------ [dependency] API&lt;=15: Adding annotations.jar to the classpath.
         [echo] ----------
         [echo] Building Libraries with 'debug'...</p>
    
    <p>nodeps:</p>
    
    <p>-set-mode-check:</p>
    
    <p>-set-debug-files:</p>
    
    <p>-check-env:  [checkenv] Android SDK Tools Revision 20.0.1  [checkenv] Installed at /app/android-sdk-linux_86</p>
    
    <p>-setup:
         [echo] Project Name: LocationLib   [gettype] Project Type: Android Library</p>
    
    <p>-set-debug-mode:</p>
    
    <p>-debug-obfuscation-check:</p>
    
    <p>-build-setup:
         [echo] Resolving Build Target for LocationLib... [gettarget] Project Target:   Google APIs [gettarget] Vendor:           Google
    Inc. [gettarget] Platform Version: 4.1 [gettarget] API level:<br>
    16
         [echo] ----------
         [echo] Creating output directories if needed...
         [echo] ----------
         [echo] Resolving Dependencies for LocationLib... [dependency] Library dependencies: [dependency] No Libraries [dependency] 
    [dependency] ------------------ [dependency] API&lt;=15: Adding
    annotations.jar to the classpath.</p>
    
    <p>-pre-build:</p>
    
    <p>-code-gen: [mergemanifest] No changes in the AndroidManifest files.
         [echo] Handling aidl files...
         [aidl] No AIDL files to compile.
         [echo] ----------
         [echo] Handling RenderScript files... [renderscript] No RenderScript files to compile.
         [echo] ----------
         [echo] Handling Resources...
         [aapt] No changed resources. R.java and Manifest.java untouched.
         [echo] ----------
         [echo] Handling BuildConfig class... [buildconfig] No need to generate new BuildConfig.</p>
    
    <p>-pre-compile:</p>
    
    <p>-compile:
         [echo] Creating library output jar file...</p>
    
    <p>-post-compile:</p>
    
    <p>-obfuscate:</p>
    
    <p>-dex:
         [echo] Library project: do not convert bytecode...</p>
    
    <p>-crunch:    [crunch] Crunching PNG Files in source dir: /home/ricky/Development/workspace/location_library/LocationLib/res<br>
    [crunch] To destination dir:
    /home/ricky/Development/workspace/location_library/LocationLib/bin/res
    [crunch] Crunched 0 PNG files to update cache</p>
    
    <p>-package-resources:
         [echo] Library project: do not package resources...</p>
    
    <p>-package:
         [echo] Library project: do not package apk...</p>
    
    <p>-post-package:</p>
    
    <p>-do-debug:
         [echo] Library project: do not create apk... [propertyfile] Updating property file:
    /home/ricky/Development/workspace/location_library/LocationLib/bin/build.prop
    [propertyfile] Updating property file:
    /home/ricky/Development/workspace/location_library/LocationLib/bin/build.prop
    [propertyfile] Updating property file:
    /home/ricky/Development/workspace/location_library/LocationLib/bin/build.prop
    [propertyfile] Updating property file:
    /home/ricky/Development/workspace/location_library/LocationLib/bin/build.prop</p>
    
    <p>-post-build:</p>
    
    <p>debug:</p>
    
    <p>nodeps:</p>
    
    <p>-set-mode-check:</p>
    
    <p>-set-debug-files:</p>
    
    <p>-check-env:  [checkenv] Android SDK Tools Revision 20.0.1  [checkenv] Installed at /app/android-sdk-linux_86</p>
    
    <p>-setup:
         [echo] Project Name: ExceptionHandlerLib   [gettype] Project Type: Android Library</p>
    
    <p>-set-debug-mode:</p>
    
    <p>-debug-obfuscation-check:</p>
    
    <p>-build-setup:
         [echo] Resolving Build Target for ExceptionHandlerLib... [gettarget] Project Target:   Android 4.1 [gettarget] API level:<br>
    16
         [echo] ----------
         [echo] Creating output directories if needed...
         [echo] ----------
         [echo] Resolving Dependencies for ExceptionHandlerLib... [dependency] Library dependencies: [dependency] No Libraries
    [dependency]  [dependency] ------------------ [dependency] API&lt;=15:
    Adding annotations.jar to the classpath.</p>
    
    <p>-pre-build:</p>
    
    <p>-code-gen: [mergemanifest] No changes in the AndroidManifest files.
         [echo] Handling aidl files...
         [aidl] No AIDL files to compile.
         [echo] ----------
         [echo] Handling RenderScript files... [renderscript] No RenderScript files to compile.
         [echo] ----------
         [echo] Handling Resources...
         [aapt] No changed resources. R.java and Manifest.java untouched.
         [echo] ----------
         [echo] Handling BuildConfig class... [buildconfig] No need to generate new BuildConfig.</p>
    
    <p>-pre-compile:</p>
    
    <p>-compile:
         [echo] Creating library output jar file...</p>
    
    <p>-post-compile:</p>
    
    <p>-obfuscate:</p>
    
    <p>-dex:
         [echo] Library project: do not convert bytecode...</p>
    
    <p>-crunch:    [crunch] Crunching PNG Files in source dir: /home/ricky/Development/workspace/exception_handler_library/ExceptionHandlerLib/res
    [crunch] To destination dir:
    /home/ricky/Development/workspace/exception_handler_library/ExceptionHandlerLib/bin/res
    [crunch] Crunched 0 PNG files to update cache</p>
    
    <p>-package-resources:
         [echo] Library project: do not package resources...</p>
    
    <p>-package:
         [echo] Library project: do not package apk...</p>
    
    <p>-post-package:</p>
    
    <p>-do-debug:
         [echo] Library project: do not create apk... [propertyfile] Updating property file:
    /home/ricky/Development/workspace/exception_handler_library/ExceptionHandlerLib/bin/build.prop
    [propertyfile] Updating property file:
    /home/ricky/Development/workspace/exception_handler_library/ExceptionHandlerLib/bin/build.prop
    [propertyfile] Updating property file:
    /home/ricky/Development/workspace/exception_handler_library/ExceptionHandlerLib/bin/build.prop
    [propertyfile] Updating property file:
    /home/ricky/Development/workspace/exception_handler_library/ExceptionHandlerLib/bin/build.prop</p>
    
    <p>-post-build:</p>
    
    <p>debug:</p>
    
    <p>-pre-build:</p>
    
    <p>-code-gen: [mergemanifest] Merging AndroidManifest files into one. [mergemanifest] Merging manifests from project and 2 libraries.
    [mergemanifest] Warning: [AndroidManifest.xml:3,
    AndroidManifest.xml:3] Main manifest has  but library uses targetSdkVersion='16'
    [mergemanifest] Note: main manifest lacks a  declaration, which defaults to value
    minSdkVersion or 1. [mergemanifest] Warning: [AndroidManifest.xml:3,
    AndroidManifest.xml:13] Main manifest has  but library uses targetSdkVersion='16'
    [mergemanifest] Note: main manifest lacks a  declaration, which defaults to value
    minSdkVersion or 1.</p>
    
    <p>BUILD FAILED /app/android-sdk-linux_86/tools/ant/build.xml:616: null</p>
    
    <p>Total time: 2 seconds</p>
  </blockquote>
  
  <p><strong>EDIT</strong></p>
  
  <p>I looked into <code>/app/android-sdk-linux_86/tools/ant/build.xml:616</code> and found that the following line threw the null <code>enabled="${manifestmerger.enabled}"&gt;</code> </p>
  
  <p>here is the entire block
      
          
      </p>
  
  <p>I am going to try to disable the manifest merger option an see what happens</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>It would seem that removing manifestmerger.enabled=true from project.properties has solved my problem. The project now compiles and works perfectly. I think I should report this bug to the android team. My manifest has the following entry </p>
  
  <pre><code>&lt;uses-sdk android:minSdkVersion="7"  /&gt;
  </code></pre>
  
  <p>However onActivityResult() still isn't called if I raise the targetSdkVersion higher than 7, so this doesn't really solve the root problem, but my project is now working properly</p>