title: Developing Android 9.0 eSIM LPA (system app)
body: <p>Trying to develop android LPA system app for eSIM with the new Pie <a href="https://source.android.com/devices/tech/connect/esim-overview#making_an_lpa_app" rel="nofollow noreferrer">API</a>.</p>
  
  <p>The doc says to extend the abstract EuiccService class. But this class is not in the official SDK, and the link in the docs just leads to corresponding file in the android source repo.</p>
  
  <p>I tried using this file/class as a dependency, but it references other internal android classes/annotations and causes build/IDE errors.</p>
  
  <p>Does anyone have an idea how to use this? </p>
  
  <p>Do I really have to pull android src code and somehow reference required class from it?</p>
  
  <p><del><strong>EDIT</strong>: I think I've solved it, found couple of potential solutions, but they were a bit cumbersome. Used the android.jar from here: <a href="https://github.com/anggrayudi/android-hidden-api" rel="nofollow noreferrer">https://github.com/anggrayudi/android-hidden-api</a> (contains modified android.jar with hidden APIs and internal resources). It didn't work when i replaced the whole file and resulted strange build errors, but i manually transferred the android\service\euicc\ folder to original android.jar of android-28 sdk and it works perfectly (class is available and apk builds without issues). And no need to waste time pulling and building AOSP.</del></p>
  
  <p><del><strong>EDIT #2</strong>: apparently not fully fixable atm. There's issue with android gradle plugins (at least 3.2.x-3.3.x) where during full sync some build task generates mock classes from android.jar and process fails if it's modified (discussion is here: <a href="https://github.com/anggrayudi/android-hidden-api/issues/46" rel="nofollow noreferrer">https://github.com/anggrayudi/android-hidden-api/issues/46</a>). Error looks like this:  </del></p>
  
  <p><del><em>Failed to transform file 'android.jar' to match attributes {artifactType=android-mockable-jar, returnDefaultValues=false} using transform MockableJarTransform</em> </del></p>
  
  <p><del>There's a workaround for that, though inconvenient:<br>
  when you need a full sync for the project, replace the android.jar with original, run sync, restore modified android.jar, the IDE now will run indexing and classes will be available again with build working until next full sync.<br>
  Will update this post if/when it's fixed or new solution is found.</del></p>
  
  <p>EDIT#3: here's probably a final solution for EuiccService case (turned out pretty obvious):<br>
  Instead of adding 'android/service/euicc' folder to android.jar, just put it in a separate library and add it as a compileOnly dependency. Since the classes were not in the SDK, the lib should not cause conflict (would be the case if you need to use modified framework or access hidden APIs in already existing classes).</p>